Enemy pathfinding AI in which the enemy only moves a fixed distance along a grid every time a button is pressed

I’m trying out the GDevelop BIG Jam (due Saturday) and one of the first things I tested no longer works, and I’m not sure what I changed.
I’m making a game where the player can move one space at a time along a grid. If in enemy character is within range, I’d like them to begin following the player, but only in angles multiples of 45 degrees along the grid and only one space whenever the player moves (and there are walls to navigate around) I’ve set the enemy up to move different directions based on different pathfinding angles while the pathfinding acceleration remains zero, triggering once when the player moves (which turns a variable on and off) and when it isn’t already moving (via another variable).
I’d include code but I’ve gone through so many different versions trying to fix it that they probably each have their own new problems and I don’t remember my thought process for all of them. It either moves once, then stops, or ignores the walls with the obstacle behavior, or starts to move once and retracts, or something else.
I know that’s not convenient but if anyone here thinks they’re experienced enough to figure out how to do this like it’s nothing, I’d appreciate your advice. Thank you.

I can think of 2 methods.

If you use the default pathfinder, you can trigger the pathfinder move just to get the 1st node. Then move to the 1st node. This is troublesome because sometimes it creates nodes at each grid point other times it only creates the fewest needed nodes. I think it creates nodes at every grid point when it set to not allow diagonals. So, it might not be the best way.

The other way is similar but uses linked pathfinder. It plots a path using objects. You should be able to do something similarly. Do a path just to have it create the path. Then use the position of the next node.

I don’t have the time to test either method. I had a post fairly recently on the subject.

1 Like