mouse click movement

0 favourites
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • You could try the system 'compare values' condition.

  • I used CustomMovement to create this effect.

    I made object variables for the player target X and Y. When the mouse is clicked I set target XY to the mouse XY.

    Then I just compare the players XY against his target XY and if they differ I turn the player sprite towards the target XY and give him some acceleration.

    When players is near the target XY I stop the movement.

    Example capx here

    I guess you can use bullet behaviour also the same way.

  • TheLure: the link to your capx isn't working. Is it in the public folder?

    Ashley: Thanks for the hint, i got that mostly working. Unfortunately, the sprite keeps creeping past the mouse click point.

    Sorry Havok, I'm not trying to hijack your post.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • TheLure: the link to your capx isn't working. Is it in the public folder?

    Agh, there was a space hidden in the end of the URL and I cant edit the post.

    Here it is again

  • Where can I get more documentation about how to use the bullet system for this (I'm not getting any good results)?

    Thanks.

  • TheLure: the link to your capx isn't working. Is it in the public folder?

    Ashley: Thanks for the hint, i got that mostly working. Unfortunately, the sprite keeps creeping past the mouse click point.

    Sorry Havok, I'm not trying to hijack your post.

    No problem at all!

    The Lure. Thanks a bunch... thats another way of working it but still is a little off (ALMOST there though). The arrow keeps on moving (like it has inertia ) I'll play a bit with this as well .

    ASHLEY. It's probably niche and minor... but I certainly think that Construct 2 can do with a Movement behavior specifically for this. Click to move to a point, with an option to constrain x or Y and then maybe a set speed as well would be great. Will this be at all doable in a future update?

    It's obviously something a lot of people could use and is finding a bit difficult. it's also a movement feature that's used pretty often in certain types of games.

  • You can do it with the bullet movement and 2 events: example

    I don't like making behaviors to replace such simple events. If we have many behaviors that do such simple things for you, I think Construct 2 will become patronising, and then people start expecting behaviors to do everything for you, which they're not designed for.

    I've included that example in the next build's example directory too.

  • Thanks Ashley!

    That works perfectly!

  • So, I've recently come across a strange bug. First, I implemented the exact events of your click-move project. Then I added my own event that rotates the sprite according to the mouse position. However, when I do this, clicking exactly below the sprite causes it to move straight left or right for no reason.

    Do you know any way I can alleviate this problem?

  • Oh silly me, I forgot the code:

    Event: If Player Bullet Speed = 0

    Action: Player Set Angle Toward Target.x Target.y

  • I used CustomMovement to create this effect.

    I made object variables for the player target X and Y. When the mouse is clicked I set target XY to the mouse XY.

    Then I just compare the players XY against his target XY and if they differ I turn the player sprite towards the target XY and give him some acceleration.

    When players is near the target XY I stop the movement.

    Example capx here

    I guess you can use bullet behaviour also the same way.

    For your example TheLure I would suggest adding one more action to your Mouse Click event "Set CustomMovement Overall Speed to 0"

    This prevents the player sprite from circling the target when a second click is performed before the previous move has been completed.

    Though I did find it quite fun to try and get the player to stop moving with more clicks before I implemented the speed cancel. Your example helped me a lot :)

  • You can do it with the bullet movement and 2 events: example

    I don't like making behaviors to replace such simple events. If we have many behaviors that do such simple things for you, I think Construct 2 will become patronising, and then people start expecting behaviors to do everything for you, which they're not designed for.

    I've included that example in the next build's example directory too.

    Sorry to bump an old thread, but this seemed relevant to me right now. The behaviour i want was achieved via Kyatric's Automated movement.capx but with the 'set angle' turned off. This makes the sprite move to mouse location while not rotating the sprite (the way i want it). My goal is to basically play different animations depending on the angle the character moves at (that part i got covered). Doing it with bullet movent also rotates the animation though and i cant seem to find a solution that way.

    Is there a way of doing this by way of your example, Ashley? I've tried turning off "Set Angle" off but this keeps the bullet movement to the original angle (as one would expect.

  • silvereon:

    When you turn off the "Set angle" property, you control the bullet with the "Set bullet angle of motion" action. To play different animations based on angle you need to use a condition like "System: Compare Two Values" and compare "Sprite.Bullet.AngleOfMotion" with whatever you had in mind.

  • Yeh i know how to play different animations based on angle of motion.

    And adding action "Set Angle of motion" to value "mouse.X, mouse.Y" - i get an error "Syntax Error - expression seems to stop here" and it points in between the mouseX and mouseY.

  • silvereon:

    That action expects an angle and not a position, so you need to use the angle expression:

    angle(YourSprite.X, YourSprite.Y, Mouse.X, Mouse.Y)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)