Even with FCriticalSelection locks I'm getting data race errors. Any suggestions?

You can maybe use the grid 2d macro as a start point to build your grid

grid macro

You can do box traces of a set size. Set a cell size and use box traces of a half size of the trace (if I remember correctly) then you can catch obstacles and passable terrain.

You can the build the map dynamically via the x y coordinate and discovered contents of the trace. (probably best via actor tag checks)

You should probably try converting the find function to be an async function with a completed / fail state. On complete it should return the points of the path.

You could consider converting the actor to a blueprint library with static functions. Then it could be accessible from anywhere in the project with no instance.

The grid method is ok for smaller levels but it will get tougher to calculate on larger levels as the density of possible path sectors will increase dramatically especially on open terrains.

Also if you are still continuing the tower defense game from previous posts then if you are going to have many units then perhaps flow fields might be a better solution

Not to debunk your current work, just giving you a tool to the toolbox if it gets too complex with more units.

Also a good thread on multi-threading

1 Like