How do I use Pathfinding with 8direction

0 favourites
  • 3 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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

  • Try Construct 3

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

    Try 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)