Use Pathfinding in a Turn Based Context for one "Step"

How do I …

Use the Pathfinding Algorithm but only for one “Step” in my Gridbased Setup where Player and Enemies move turn by turn

Situation …

I have a player (white sprite, pixelperfect grid movement), and two enemies (yellow and red sprite, using pathfinding, virtual grid data = player movement data) and obstacles (pink sprite, pathfinding obstacle). After the Player moves, the Enemy Action / Move should be triggered. Everything “works” fine regarding Pathfinding and the enemy(ies) move to the Player avoiding Obstacles perfectly on the right path.

But of course, the enemy(ies) move to the player in one smooth event. I couldn’t find any approach how to get the Pathfinding “Next Node” or “Next Step” to just let them move one Correct Move of the constant Distance. I tried to add PixelPerfectmovement and do it like I do with the player (Chaning the state after a movement has happened) but it is one smooth movement without any chance to interrupt. I also tried to meassure the moved distance and stop it. But this approach doesn’t seem right.

Any ideas, links, examples? Thanks in advance

I was just about to try something complex with tiles IDs when it came to me. You can get the angle to the first node and then move to it based on angle and distance. I used a variable to make it easier to read but it’s not needed. I used a grid 64x64 and disabled diagonal movement. I added a button for testing.

Thank you, defintitely pointed me in the right direction somehow. I am using a move to player that calculates and stores the path and afterwards a move again that takes the coordinates of the first node.

Afterwards I “break” the condition, to make it “one step”. Works fine, the double call of the move ist just a little strange. There should be a calculate actual Path or sth. that just stores the waypoints or steps :smile:

1 Like