A* pathfinding

Hello everyone,
I came across some similar questions before, but couldn’t find an answer.
Is actual A* implemented in UE4? If yes, how do I find it and use it?
Thanks a lot in advance.

I’m not 100% sure about the implementation used in Unreal. If I had to guess I’d say it’s probably a modified A* but no guarantees here.

However I can tell you a bit more about what you can do and how the implemented pathfinding works.

As you may or may not know Unreal uses a NavMesh. A NavMesh is a grid of triangles which are placed (in UE4 automatically) in the 3D environment. The area within the triangle is walkable and we have 3 edges that we can move to from each part.

By default pretty much everything is taken over by unreal. You just need to make sure there is a nav mesh around (you do so with a nav mesh volume and can verify it by pressing “P” while in viewport which toggels a visualization of it).

However you can take over certain parts or even most of the actual pathfinding in the ways described in the following answerhub thread:

1 Like

Thank you very much for such a detailed answer.
Maybe you could recommend how and where I can implement my own pathfinding algorithm?

UE4 is supposed to be using a generalized A* algorithm. It receives a fixed set of nodes and produces the shortest path, to my recollection.

I use this vagueness because our project required A*, but we had to do some particularly strange things with the nodes first, so we had to make our own algorithm at the time. That said, I know there is an A* algorithm which claims to be generic in the engine.

If you want to examine the code that goes into Unreal Engine 4’s pathfinding I suggest examining the source code:

UnrealEngine/Engine/Source/Runtime/AIModule/Public/GraphAStar.h

If you don’t have the source code available from your project you may want to instead look at this, which allows you to search through the github repo when configured right. Unreal Engine on GitHub

Thank you for your help.
Do you know which function exactly out of many navigation functions (AI MoveTo, Move To Actor or Location) uses A*? I couldn’t find any information in documentation.

I’m quite comfortably certain that all of those use A* - that said, I haven’t examined them too closely, but from what I’ve gleaned they all generally resolve to the same Navmesh system found in the AIModule stuff.

Thank you very much again :slight_smile: