How do I set a animation based on mouse's position?

0 favourites
  • 8 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Hey there, im new to the community! Just got this amazing software a couple days ago and im still learning the basics before i can in fact focus on my own game. =D

    But, im stuck for a while already, and i've searched everywhere, tried many different ways, but without success... Im trying to make my character run a specific animation as it moves to where i pointed with mouse (its moving ok to the position, but as a static sprite). I was messing around trying to get the mouse' angle, position, but it never worked for all 8 movement animations (4 diretions plus 4 diagonals). Someone enlighten me, please.

    Thanks in advance! o/

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • which method (behaviour) are you using for the movement?

  • which method (behaviour) are you using for the movement?

    Pathfinder.

  • You can get the moving-angle of your sprite with the expression

    Sprite.Pathfinding.MovingAngle

  • You can get the moving-angle of your sprite with the expression

    Sprite.Pathfinding.MovingAngle

    Didnt work.. =/ Maybe i put them on the wrong place, but the system didnt recognize these expressions... Can you be more specific about how/where should i use this expression? sry, im a newbie yet..

  • you probably want to know if the player's moving angle is between certain agles to switch animations, so this is how:

    first set rotate off in the pathfinding properties.

    (YourSpriteName) pathfinding is moving along path

    System is between: (YourSpriteName).pathfinding.movingangle -between- 22.5 -And- 67.5

    • set animation to down-right

    (YourSpriteName) pathfinding is moving along path

    System is between: (YourSpriteName).pathfinding.movingangle -between- 67.5 -And- 112.5

    • set animation to down

    etcetera..

  • you probably want to know if the player's moving angle is between certain agles to switch animations, so this is how:

    first set rotate off in the pathfinding properties.

    (YourSpriteName) pathfinding is moving along path

    System is between: (YourSpriteName).pathfinding.movingangle -between- 22.5 -And- 67.5

    - set animation to down-right

    (YourSpriteName) pathfinding is moving along path

    System is between: (YourSpriteName).pathfinding.movingangle -between- 67.5 -And- 112.5

    - set animation to down

    etcetera..

    Hey, thank you so much for your help! It really works now the way i wanted! \o/

    I was trying before with a different behavior (Pathfinder, instead of Pathfinding as you suggested), now the character moves really smooth in all 8 directions, except to the right, which is the spot that theres the angle between 340 and 20, and i dont know what i should put in the expression to make the 340 ''jump'' through the 0 instead of 'running' all the way back. Any idea on this? Its probably very simple but im still to newbie to figure it out.. lol

  • No problem

    for the 340/20 issue you can just use -20 and 20..

    Good luck with the rest of your Game!

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