So I’m trying to make a grid-based movement system in Unreal Engine 5, and it’s one where you’re on one tile and you can only move to one of its neighbors at a time.
And I’m trying to make the controls similar to Legend of Grimrock, where you move using WASD and use Q and E to rotate. Here’s what I’m using as far as programming goes:
For the top one, it’s the same for the other three movement buttons, only in different directions (Forward, Backward, Left, and Right)
This photo above tells you what I have so far. A mite barebones and obviously unfinished, but I want to make it so the keybinds will use WASD regardless of rotation while still maintaining the “neighbor” system that’s in place here.
Are there any ways to pull that off with what I have so far? Thank you very much in advance!
1 Like
I think you’ve kind of hidden code in your tile structure. Here, for instance:

How can you know which way is forward when you make the array?
Just to be clear: Do you want W to always move the player in the direction they are looking, or always move ‘north on the map’?
1 Like
I want it to move when I press W regardless of which direction I’m facing.
Instead of keeping a huge array of where all the tiles are etc, you can just put them in the map and use GetActorForwardVector and a line trace to find out what the next tile is.
Do you need some help?
( I need to know things like ‘are the tiles blueprint?’, ‘do they have a collision volumne?’ etc )
1 Like
Sure, I’d love some help! Here’s what I used to make the array:
So as you can see, going from up to down: I have data assets regarding which direction any neighboring tiles will take you, reading how far they are and whether or not you can travel to them. When I press a button that says, Reset Map, I delete everything and clear the entire thing before creating a new one based on the value of the Width and Height components and attaching them to one another while binding them to Location, Rotation, and Scale Rules of Keeping World.
I also have 2 assets to fit into this grid as of right now: a floor that you can traverse on and a wall that blocks your way.
I think you’re giving yourself a hard time. I will set something up, it’s going to be a bit later though…
1 Like
So this pawn will only walk on the tiles, and understands when a tile is missing and won’t walk on the gap.

There’s no array of tiles. I just made a tile BP. It just has a flattened cube, and a collision volume set to block all
When I try to move forward, the pawn does a line trace to see if there is a tile there. It ignores the tile underneath:
If there is a tile, then it moves forward. Both the forward movement and turning are locked with a DoOnce, until the code is happy the pawn had finished the movement:
I just use tick to re-align the pawn and check if it’s ok to enable movement again
2 Likes
OHHH, this is amazing! Thanks, man!
1 Like
It’s not perfect, but you get the idea.
At the moment, moving to 0,0,0 won’t work
and the pawn moves to where the line trace ends.
I made sure the line trace is exactly the distance to the next tile, but it is possible where hundreds of tiles, things could go out of whack. So, once the trace is successful, use the location of the chosen tile to move to…