Traditional Roguelike AI Pathfinding

Hi all, I’m back again.

I am looking to add pathfinding for AI in the traditional roguelike I am working on, but I am not exactly sure how to, due to my level of experience. I’ve seen some forum posts on here about the issue at hand, but they unfortunately weren’t clear enough for me to follow.

Essentially: The enemy should only move one 64 x 64 cell at a time, like the player is doing. towards the player. But I do not know where to get started, or how to properly implement a grid for the enemy to follow.

Here is a screenshot of what I have so far, The variable TurnGeneration is the “turn-in-progress” mechanic. It is what holds all the info needed to complete a turn.

ezgif.com-video-to-gif-converter (1)

Here is a gif of how the player moves, so you can understand what I am talking about.

I apologize for the lack of experience. However, I do believe once I get passed this obstacle that I will be good for a while.

1 Like

This is the farthest I could get with this. As you can see, it still does diagonals and does not stay proper to cell size, but I am also probably using the pathfinding behavior wrong.

ezgif.com-video-to-gif-converter (2)

Thank you in advance.

I don’t see any events usjng the pathfinder behavior.

If you’re using a tilemap with collisions then you can’t use the GD pathfinder, you would need to use the nav mesh pathfinder. The GD behavior uses the objects overall size for obstacles. So, it sees the entire tilemap as an obstacle. The Nav Mesh behavior uses the collision mask.

I’m not sure how to move just 1 block with the nav mesh. You could get the direction from the object to the location of the next node. You could then either calculate the position or I guess add force in that direction.

I wanted to do that as well look at this vid MrMen sent me. :point_down: