0 Favourites

How do I use Pathfinding with 8direction

  • 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.

  • 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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,124
karshinkoff's avatar
karshinkoff
Unread hot topic
105 16,945
Magistross's avatar
Magistross
Unread hot topic
56 4,726
MPPlantOfficial's avatar
MPPlantOfficial