Download

Modify pathfinding to use straightened paths

Hey there,
I use Unreal’s V1 navigation system to find a path between two points. It’s very straight forward to find a path in C++, but the path isn’t that optimal for me, since it goes straight from point A to B (diagonal). Since my game is tile based, I want more of a A* styled approach which goes a straight line as far as it works and then diagonal. Here’s a picture showing that:

The green debug line is how it currently generates the path, the red thick line is how I want it to work. Is there a way of changing that, maybe with movement costs?

Thanks for your help!

If your map is based on “cells”, you’d be on better shoes if you build a custom A* for it where 1 cell = A* unit.

Yea I did that a while ago, I just wasn’t sure how to integrate the raycasting in it so it will block paths through walls and stuff like that. Do you have an idea for that?

The walls should follow cell snapping as much as the floor does; any cells where there’s a wall’s mesh/Blueprint/flag/collider/etc automatically should turn into a dead cell even before any pathfinding runs.