Checking movement direction for animation change

This forum is currently in read-only mode.
From the Asset Store
Rotate & Animation for 16 Direction & Mouse Direction
  • I'm working a simple game in which I have some mobs that wander in a random direction for a random amount of time. For this I applied a custom movement behavior and and use the "Change speed towards angle" with the speed set to a global variable and angle is "random(360). This part works great and does what it needs to do. The problem that I am having is trying to figure out how to change the animation based on the direction of the enemy on the X axis ( a simple left or right). I don't know how to perform a check based on direction.

    I tried to search for a solution to this, but I'm no programmer I don't know the proper terminology to even search for, so if there is a post about this already, I apologize and help whatsoever will be greatly appreciated.

    Thanks

  • Make a variable, old_x

    + old_x is greater than sprite.x

    change animation to "left"

    + old_x is less than sprite.x

    change animation to "right"

    + always

    set old_x to sprite.x

    Guess what this does!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ...or in the event you set the angle, add two subevents (system compare, else):

    (system compare) AngleDiff(0,mob.angle) less or equal than 90

    +change animation to "right"

    else

    +change animation to "left"

    Edit: forgot to type what to compare to :s

  • Sweet guys... I appreciate the help here. I will try these suggestions and let ya know if it worked or not.

    Thanks again.

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