A* Custom pathing

I am creating a custom path node system to use as the default unreal isn’t for flying things

I have created a component that i am using as a path node to use in the A* algorithm.
i have collected these components in an array in a separate navigation class that is used to search the array and return a rout.

The system works when only 1 pawn is using the system. I am assuming that it doesn’t work with multiple pawns as each pawn can be accessing the nodes at the same time if they are in different threads.

is there a better way to deal with this issue other than creating a struct for each path node in each pawn and copying the components relevant details e.g. g,h,location, etc ← i don’t want to do this for performance reasons if i can do it a better way.

with your responses bear in mind that i am a novice coder and will probably need very basic / step by step explanations.

I’m not doing to give you step by step instructions, because that would take a lot of time to write it down (actually it would be quicker to just implement it! :smiley: ) but I’ve figured it’s better to give you a answer than to give you nothing.

I’d suggest you created a new navigation data type. You do that by implementing a class inheriting from ANavigationData. This will allow you to add custom FindPath implementations (see how RecastNavMesh does it). Once you have the new navigation data type you’ll need to add a supported agent information, this one’s trivial, just go to Project Settings → Navigation System and add an entry to SupportedAgents array and have the new entry point at your navigation type. If you don’t use any other navigation type in your project this will make your navigation type be the main navigation type for the game, and that means you don’t need any additional setup, all the PathFollowingComponents and generic FindPath calls will take advantage of your code.

One note, unless you manually make sure your code runs on multiple threads the gameplay code in UE4 is always run in a single thread. It’s a strong assumption and unless you really have to go wide I would strongly advice to stay on the game thread (especially if you’re a novice coder).

Regarding A* implementation that can be used by multiple agents at “the same” time see if you can figure out how to use FGraphAStar. We’re successfully using it both in Paragon and Fortnite, but there’s not example of usage in the engine/AIModule code just yet (sorry!).



TY for your time. What you said made me realise that what i thought the issue was (threading) was not the problem. the issue was that the logic had a flaw that made the process take 2 ticks not 1 so the pawns messed with each others result