Unreal Engine 4 Dev Update #9: Navigation Path Display for Pawn Movement

In one of the earlier dev updates, I had written about the movement grid system that I had implemented. If you haven't checked it out yet, here's a link:

Unreal Engine 4 Dev Update #5: HUD based Command UI, Grid based movement system & Dynamically Spawning Grids

Basically all the pawns in the game are moving based on grids of 100x100 units. In it's current form, it only works for plane surfaces. I'll have to modify it to meet the requirements for curved surfaces, but for now, it's working fine for prototyping on flat surfaces.

Unlike most Turn-Based games, where units moving from one grid to another travel along the path connecting the grid centers, I plan to have free movement between the grids. This is very similar to what was implemented in XCOM: Enemy Unknown. I feel that free movement is the way to go for Turn-Based shooters, as otherwise, the movement feels very constrained. As a result, I'm using Unreal Engine's default navigation system, instead of going for a custom A* pathfinding algorithm. There are some occasional issues with the navmesh, when it comes to finding the shortest path. But I'm guessing that I can deal with the very obvious issues through adequate level design measures. If it proves too buggy in the future, I'll probably check out Monokkel's custom pathfinding algorithm that'll release soon in the marketplace.

So anyways with the current setup, as you might have seen from earlier posts, I do not have a permanently visible grid system. It's spawned dynamically based on player input and destroyed after it's use. As a result, I wanted to give the navigation path details to the player, when he wishes to move his unit to a new location. And fortunately, there is functionality in Unreal Blueprints to find the path that the player's unit will take from it's current location to any other location. So using that I was able to get path points towards any accessible location as soon as player clicks over there. I then used this data to create splines from the starting point to the target location, along the path points that I had earlier obtained. As a result, the player can always see the path to this target location before he makes his move. More so than it's aesthetic function, this data will be really useful in order to devise a good tactical move, if reaction shot functionality is added to the game. In it's current form, the pathing spline is not very smooth at the turning points. That's something that I have to deal with later on. But apart from that, it functions kind of similar to the path display from XCOM.

Here's a recording of the path display in action. As I mentioned in my previous post, I have removed most of the materials and toned down the graphics settings.


Recently, I noticed that there were pathing issues when moving around other units. By default, the pawns placed in the level do not affect nav mesh generation. As a result, the pawns didn't take the other pawns into account when generating their navigation path. So they just collided with any other unit in their path, thus halting their movement before reaching the destination. At first, I set the pawns' root capsule to affect nav mesh generation. But even in this case, I faced an issue, as the pawns were moving too far from each other due to their combined wider region of effect on nav mesh. I had to enable run-time navmesh generation and have the pawns effect the navmesh dynamically in order to rectify this issue. I now disable the active pawn's effects on navmesh, while having the remaining static pawns effect the navmesh. This way the pawns are able to path around each other fairly easily. And that's where I'm gonna leave it for now, while I move on to handling the pawn attributes and combat.

That's all for this update. You can check out more unreal dev videos in my Youtube channel:

Popular Posts