How do I make paths in 45 degree increments?

0 favourites
  • 4 posts
From the Asset Store
Pixel Enemies for SHMUP consists of 45 enemy ship sprites to be used in your game.
  • I've been using the pathfinding behavior and I'm unable to figure out how to restrict the path to only having 45 degree increments. I believe this is the Manhattan algorithm and can be easily implemented if this is an A* system. If I'm unable to do that then how would I be able to fake it? I've tried setting different 8 direction walking animations to an object depending on the angle of rotation the object actually using pathfinding is currently set to, but the results look like crap. For example if a sprite is animated to look like it's walking at 45 degrees but it's actually moving at a 60 degree angle across the screen it's obviously wrong and very noticeable.

  • You could try using a Between value condition to check the Sprite.Angle and then have it like:

    if 44 < Sprite.Angle < 46

    or

    89 < Sprite.Angle < 91

    or

    134 < Sprite.Angle < 136

    or

    179 < Sprite.Angle < 181

    or

    224 < Sprite.Angle < 226

    or

    269 < Sprite.Angle < 271

    or

    314 < Sprite.Angle < 316

    or

    359 < Sprite.Angle < 361

    then do movement

    else do nothing (or maybe reorient the sprite using +/- degrees until it is in one of those avenues)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That doesn't work because if you use the movement I can't calculate how far I'm supposed to move it and then the game looks like it has extremely broken pathfinding.

  • Well put it on a looping check function and just adjust the degrees by like 0.1 or so. That way it will stop, do a slow turn until it is within the directional parameters and then move forward.

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