Find Path to Location Synchronously creating weird paths

Hi,

I am creating an RTS game were the movable units are non-skeletal i.e. they are only static meshes (procedural ones in fact). As there is no possibility to use the standard AI navigation like Simple Move to Location etc. with non-character actors, I found a function called Find Path to Location Synchronously. The paths are perfect when a mesh has to avoid another actor, but whenever I order a unit to move to a location and there is nothing to avoid, it follows an unnecessary curve before actually going in a straight line towards the target location.
Here are two draft images depicting the problem:

The actor is a simple static mesh consisting of cubes (generated procedurally), so it can move in every direction as it is not a character and has no pre-defined front. I am wondering if the problem occurs due to the box collision mesh that is assigned to the unit. Maybe it makes a bigger “hole” in the NavMesh than the capsule components in characters, thus UE tries to construct a path avoiding a hole in the NavMesh created by the unit itself.

Maybe it’s because the actor can only move forward and isn’t looking at the target at the start of the movement, and his rotation takes time? You should post screenshots.

Posting screenshots with navmesh drawing enabled would help the discussion a lot. But I think I know what’s going on. Your “characters” cut holes in the navmesh (right?) which means their paths don’t start at their locations since there’s no navmesh there, instead paths start at a point on navmesh closest to the actual character location. See this thread for a discussion on this issue

However I have a high-level comment for you: if you you plan to have many “characters” in your RTS game using runtime navmesh generation for character avoidance is not a valid option. Our runtime navmesh generation is fast, but doing a lot of it will cost you lots of CPU. Have you tries using detour crowds?

One thing that can help with the performance however is making your characters’ static meshes navigation dynamic obstacles (there’s an option in Static Mesh editor). Also, creating a very expensive yet traversable navigation area and using that instead of the default “null” area for obstacles would solve the pathfinding problem you experience.

Cheers,

–mieszko

Thanks for the explanation, I suspected the holes in navmesh might cause the problem.
I have some c++ experience, but still my project is BP-based and I don’t know a way of implementing detour crowds through BP.
The second solution is really appealing, but how do you create such navigation area with a certain path cost?

Create a BP derived from NavArea and modify its default properties :slight_smile:

Um… I have watched some tutorials regarding navigation, however, I am slightly lost now.
I have my Nav Mesh Bounds Volume that is rebuilt at runtime and that is basically all I have for now, so what should I do with the NavArea blueprint?

Open your character’s static mesh in the Static Mesh editor, find the Navigation section in the properties and play around with dynamic obstacle’s options.

So I checked the Dynamic Obstacle option. I tried plugging my new NavArea BP to the Area Class property in navigation tab in static mesh editor, but it does not change anything.
There are also some collision properties in the navigation tab and maybe I could set something here, so that the characters punch out smaller holes in the NavMesh. But still the collision meshes assigned to the static mesh are blocking most of the other actors and consequently affecting the NavMesh, so I don’t think this would work.
Edit:
Ok, now I did something that might work, but does not want to. I added a NavModifier component to my unit and set the Can Ever Affect Navigation property in my static mesh component to false. But the NavMesh occurs only around one instance of the unit. Any other spawned unit does not change the NavMesh at all, even though it is updated in real-time.

Ok, here are some screenshots of what happens when I have my NavModifier with a specified Area Class:
In editor (before running) - every unit modifies the NavMesh

During runtime:

You do have runtime navmesh generation enabled in Project Settings, right?

Yes, I have both Build Navigation at Runtime in Navigation System tab and Rebuild at Runtime in Navigation Mesh tab enabled.

I noticed that potentially the navmodifier somehow affects the NavMesh only in the 0,0,0 world point and is not translated along with the units:

How do you translate your units?

They are simply moved by Set Actor World Location function.

You’re going to get into lots of trouble using that for “movement” :wink: It’s more of a teleportation tool than movement… but it should work.

What class are you using for your characters? Have you tried using Pawn or Character? If you used those you’d have access to “movement component” that would implement movement for you, with stuff like collision and navigation paths taken care of for you.

Please let me know what class are you using as a base for your character BP so I can file this issue and have it solved.

I wanted to make them all pawns, but had to change them to BP deriving from actor class, because for a character/pawn I somehow could not implement the functionality I needed. Additionally, I add static mesh components throughout the game to the unit actors.

Ok, so I managed to get the real-time NavArea changing to work. It was a problem with references between the static mesh component and the static mesh asset.
I have one last question. If somehow I replaced the actor BP with a pawn/character BP what would the way to make them move? From my experience I know that for non-skeletal meshes the simple move to location/actor functions do not work.

I don’t see any reason for Simple Move To function family not working for non-skel mesh pawns. If it doesn’t then it’s a bug that we’re not aware of. If that’s still the case it would be ideal if you made a stripped-down version of your project and send it my way so that I can just make it work.

Also, there’s a lot more move-related functionality in AIController, which gives you more flexibility and control over movement requests.

Thank you for all your help.
Do you know any tutorial which shows the setup of a pawn/character from scratch? Because all I see are some videos where the character is already set up. Maybe I forgot about something when setting up my pawn and it is a reason for the Simple Move to function not working.