Custom Grid-Based Player Movement
- kevinmeergans
- Jun 20
- 2 min read
Updated: Aug 14
The world of Mushroom Kingdom is based on a square grid, with all static objects properly aligned to this underlying structure. Similarly, all pawns, including the player, should stick to the grid cells when navigating the world. To enable this restricted movement, I implemented a custom movement actor component, originally for the player pawn, but I might extend the code to also handle NPCs later on.

To save time, I started by copying Unreal’s built-in FloatingPawnMovement component and modifying it for my specific purposes while keeping the general structure intact. For example, user input is additionally processed so that the resulting movement direction is always one of the four possible directions allowed on the grid. Also, when there's a 90-degree turn, for instance, from moving right to moving “up”, I had to make sure the player doesn't end up between grid cells. So, before reacting to a requested direction change, the pawn continues moving in the current direction until it reaches the center of the next grid cell.
For collisions, I use a few line traces to check for obstacles, drops, and surfaces that are too steep to walk on. With these traces, the pawn constantly looks ahead to make sure it's safe to move to the next grid cell, so we don’t realize something is blocking the path when we're already halfway there. Given how the environment will likely be set up, the line trace checks should be accurate enough and if needed, I can still switch to shape traces later on.
To test my custom movement, I built a decent-sized playground to account for all possible combinations of obstacles and walkable surfaces. You can see a short video of my test pawn having a go below.


