How do I correctly determine the angle of a Pathfinding Object in order to change its' Animation?

0 favourites
  • 4 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Hi there, I've been tinkering with this for a day or two now and unfortunately it's still giving me issues where the animations just won't change.

    The Object has the Pathfinding Behaviour

    And then I have this piece of code that is checking the Pathfinding.MovingAngle to determine the Animation required.

    However, often the Object never changes its animation or sometimes chooses a completely incorrect one. I've double checked and triple checked my angles but it's obvious I'm doing something wrong here. I would really appreciate a second set of eyes on this.

    The most common one is when the Object should be playing the Walk Right animation (as it's within the angles specified) it plays the Up animation instead.

  • As is always the case, you try things out when you've posted on the forums ... it looks like it is now fixed with the following change

    + System: Pick Demons by evaluating Demons.Pathfinding.MovingAngle >= 315 & Demons.Pathfinding.MovingAngle <= 360

    + Demons: Is Pathfinding moving along path

    -> Demons: Set Direction to 1

    -> Demons: Set animation to "Walk_Right" (play from current frame)

    + System: Pick Demons by evaluating Demons.Pathfinding.MovingAngle >= 0 & Demons.Pathfinding.MovingAngle < 45

    + Demons: Is Pathfinding moving along path

    -> Demons: Set Direction to 1

    -> Demons: Set animation to "Walk_Right" (play from current frame)

    + System: Pick Demons by evaluating Demons.Pathfinding.MovingAngle >= 45 & Demons.Pathfinding.MovingAngle < 135

    + Demons: Is Pathfinding moving along path

    -> Demons: Set Direction to 2

    -> Demons: Set animation to "Walk_Down" (play from current frame)

    + System: Pick Demons by evaluating Demons.Pathfinding.MovingAngle >= 135 & Demons.Pathfinding.MovingAngle < 225

    + Demons: Is Pathfinding moving along path

    -> Demons: Set Direction to 3

    -> Demons: Set animation to "Walk_Left" (play from current frame)

    + System: Pick Demons by evaluating Demons.Pathfinding.MovingAngle >= 225 & Demons.Pathfinding.MovingAngle < 315

    + Demons: Is Pathfinding moving along path

    -> Demons: Set Direction to 4

    -> Demons: Set animation to "Walk_Up" (play from current frame)

  • No, you can't compare angles like that. Use "System Is Between angles" condition and "For Each" loop. Try this:

    Demons moving along path
    System For each Demons
    
     System Demons.Pathfinding.MovingAngle is between 315 and 45 ....
     
     Else 
     System Demons.Pathfinding.MovingAngle is between 45 and 135 ....
    
     Else 
     System Demons.Pathfinding.MovingAngle is between 135 and 225 ....
    
     Else 
     .....
    
    
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thankyou dop2000 that is a much more elegant solution to what I came up with. You, are a legend!

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