Moving AI on a Grid

Hey all -

I’m currently puttering away at a 1st person dungeon crawler (Dungeon Master, Grimrock, EotB, Wizardy, etc.) and am running into an issue with getting my enemies to move tile by tile rather than from point A to B in a direct line (when patrolling or spotting the player, for example.) For the player character, I can restrict movement to 4 directions and move them a specified amount of units (512) then am doing a line trace downward to hit a tile and snap them to the middle of the tile/grid. I had tried doing the same for an enemy, and believe I am “on to something” but am totally lost on how I would make the enemy move tile by tile, like the player and calculate that into it’s path.

Player move bp, after getting axis direction:

For the enemy, right now, it’s pretty simple pawn sensing and “ai move to” though I had tried splicing the player BP stuff in with the enemy navigation to no effect…

Are there examples to check out for this type of movement / logic for enemies - or is there something obvious that I’m missing? Thanks in advance!

Okay, I have managed to get the enemy to move tile by tile randomly - though its through searching for tiles to each side and setting 4 different options, choosing those options randomly and moving to it. Though, I’m not totally sure if this is the smartest way to do it, but it does do roughly what I want - Now, though, I would need to figure out how to set a destination (like player location) and break that translation down into a series of moves like I have here. Basically, see what option is best (closest to player direction?) then using that…

[1]:249788- [2]:


[3]:

Putting an “answer” here for future reference in case anyone in a similar situation searches for this in the future and finds a dead end - I found there are at least 2 options.

1 - Developing or using an A* pathing system. Though, my knowledge of BP is pretty low in comparison, so wrapping my head around it wasn’t that simple. Beyond that, a lot of tutorials for it seem to be theory for programming (which I don’t quite get yet) or for pretty elaborate setups that I didn’t really need (like the TBS template in marketplace)

2 - For what I need, which is moving in 4 directions, I set out line traces from my enemy pointing down at the center of a tile to north, south, east, and west. Then, pick that tile to lerp over to. For roaming, you can pick one of these at random through the int using a switch…for “hunting” the player, I shoot out a bunch of line traces that look in 16 different angles to see if it hits a player…if it does, based on the degree of the “compass” (top doing going from 0 - 15) it will convert that number into a “best guess” for where to move based on the core 4 directions (i.e. if the player is towards the left, it will move to the left tile)…then does this check again after moving. It also does a check to see if the player is directly beside them first and will do an attack, if not will continue to hunt. If hunting fails, it will continue to roam. So far, this works okay for what I need but will most likely need to do something more advanced or do more checks to narrow down a better answer.