How do I mimic 4/8 sided movement with mouseclick and move?

0 favourites
  • 2 posts
From the Asset Store
_ Fully animated top down mimic chests game sprites _
  • Hi,

    Top-down style game.

    I have a player sprite with walking animations for left, right, up, and down. I am using a mouse click and pathfinding behavior to move the player. Works like a dream except I am currently only using one animation frame for up, one for down, ignoring left and right. Now it's time to evolve my game and adjust animations based on movement direction.

    Problem, since I am using mouse click, is there a way I can mimic the 4 direction movement so I can run an event that adjust the animation to the appropriate direction? What I am experiencing is that if I click 40 pixels down and 20 pixels to the right, it's only showing one movement since it's moving diagonally. So then it got me thinking about mimicking 8 direction movement. However, the question is the same...

    I understand that if I used the 4/8 sided movement behavior instead wherein WASD is used, I can easily adjust my animations to show the player moving left, right, up, or down, diagonal. Is there a trick to mimic this using my mouse click event instead of the 4/8 sided behavior?

    I was thinking of doing an evaluation constraint based on current location X,Y and the targeted location X,Y and which ever is greater, then use an animation based on that evaluation. Is it as easy as that or is there an optimal way?

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your evaluation idea is the correct way to do it. However, with pathfinding, you don't want to compare your current x and y against the destination. You want to check the pathfinding behaviors movingangle (Self.Pathfinding.MovingAngle). This will update every time the character reaches a node in the path and return the current angle at which the character is moving.

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