Animate player sprite movement with pathfinding

Get help using Construct 2

Post » Fri Aug 04, 2017 3:26 am

this is how i have managed to get it kinda working

+ Enemies: Is Pathfinding moving along path
-> System: Set angleToNode to angle(​Enemies.​X,​Enemies.​Y,​Enemies.​Pathfinding.​NodeXAt(​Enemies.​Pathfinding.​CurrentNode)​, Enemies.​Pathfinding.​NodeYAt(​Enemies.​Pathfinding.​CurrentNode)​)

----+ System: angleToNode is between 0 and 45 degrees
-----> Enemies: Set animation to "right" (play from beginning)

----+ System: Else
----+ System: angleToNode is between 46 and 135 degrees
-----> Enemies: Set animation to "down" (play from beginning)

----+ System: Else
----+ System: angleToNode is between 136 and 225 degrees
-----> Enemies: Set animation to "left" (play from beginning)

----+ System: Else
----+ System: angleToNode is between 226 and 315 degrees
-----> Enemies: Set animation to "up" (play from beginning)

----+ System: Else
----+ System: angleToNode is between 316 and 360 degrees
-----> Enemies: Set animation to "right" (play from beginning)

but as the enemy approaches the current node his animation start going crazy
B
47
S
26
G
2
Posts: 31
Reputation: 4,937

Post » Fri Aug 04, 2017 9:20 am

@piranha305 : You can use the MovingAngle expression of the official behavior as long as its speed is >0.

The "crazyness" likely comes from your angle calculation quickly changing/being unstable when you are almost at the same position as your target.
In your example, your test is also done every tick the behavior is moving.

You can refine your animations with the use of condition check of the speed/is moving and possibly the distance with the enemy/arrival node.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Fri Aug 04, 2017 11:48 pm

yes i must have been due to the calculation, i changed it to use the moving angle and its working perfectly thanks!!! i was not aware of that property, i must have overlooked it, but its awesome thanks
B
47
S
26
G
2
Posts: 31
Reputation: 4,937

Previous

Return to How do I....?

Who is online

Users browsing this forum: zsoldiers and 7 guests