How do I use Pathfinding with 8direction

Just started using Construct 2? Post your questions here

Post » Sun Feb 08, 2015 4:46 am

Hello, Im trying to make my sprite (8 direction animated) move to certain spot (with pathfinding). The problem is that I have no idea how to "connect" pathfinding with 8direction. Is there any tutorial out there I didnt find?

Thanks.
B
8
Posts: 26
Reputation: 348

Post » Mon Feb 09, 2015 8:01 am

You could use condition "System-Compare two values" and the type in "sprite.Pathfinding.MovingAngle".
You will need 8 double conditions for every combination:
One which includes 0 angle will have to look like this:
If sprite.Pathfinding.MovingAngle > 337 or sprite.Pathfinding.MovingAngle < 23 then "look east"
Others will have to look like this:
If sprite.Pathfinding.MovingAngle > 157 and sprite.Pathfinding.MovingAngle < 203 then "look west"
If sprite.Pathfinding.MovingAngle > 203 and sprite.Pathfinding.MovingAngle < 247 then "look north/west"

and so on..

EDIT
also use else between them for better performance
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 3:01 pm

razorMonkey wrote:You could use condition "System-Compare two values" and the type in "sprite.Pathfinding.MovingAngle".
You will need 8 double conditions for every combination:
One which includes 0 angle will have to look like this:
If sprite.Pathfinding.MovingAngle > 337 or sprite.Pathfinding.MovingAngle < 23 then "look east"
Others will have to look like this:
If sprite.Pathfinding.MovingAngle > 157 and sprite.Pathfinding.MovingAngle < 203 then "look west"
If sprite.Pathfinding.MovingAngle > 203 and sprite.Pathfinding.MovingAngle < 247 then "look north/west"

and so on..

EDIT
also use else between them for better performance


Awesome, thats all I needed. Thanks Razor.
B
8
Posts: 26
Reputation: 348


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests