NavMesh wont update under moving actors.

So, i was tinkering with some top down character movement and i discovered that the nav mesh does not really update after the character has moved.
obraz_2023-10-04_100651781

I tried changing the runtime mode to dynamic but that didnt change anything. I also started the provided TopDown Template and it seems that it does not work there too.

Spawned actors do not affect the navmesh and if i place the actor and move it in game the nav mes is not affected.

Am i doing something wrong?
I would apprecieate any help :slight_smile:

Explore these:

image

My CapsuleComponent has that enabled. Thats why u see the red field on navmesh. But they wont move with the characters.
image

Try the last option, Pawn.

1 Like

With only the pawn enabled there is no change in navmesh for both placed and spawned actors. (2 in the middle are placed in editor, rest are spawned while playing)


And with the capsule and pawn enabled the navmesh changes for placed actors but not for spawned. And it does not change while moving in game.

I restarted the engine. Saw that the runtime changed again to static. Changed it to dynamic. Now when pawn affect nav is on it works.
Thanks. Nearly solved.

1 Like

Does it behave correctly on your end? Because this is not as expected:

Or I forgot how to navmesh…

Now that u mentioned it. It behaves wonky. Like the pathfinding goes crazy. The character does not move in a straight line even when he can.

Something is still wrong haha.

Edit 1:
I have my path shown (using find path to location synchronously) and it does not follow the path at all in 90% of the cases.

Edit 2:
Without the fix u provided (pawn affect nav and dynamic navmesh gen) the character moves along the path correctly.

This is the first time I’m looking at the navmesh behaviour in 5.x
I can swear this was nowhere nearly as wonky under UE4. :expressionless:

Exactly.
I am rewriting this project from 4.x to 5.x and it baffles me. It worked before.

It’s been a while since I dabbled but it, kind of, makes sense - the more I think about it at least. If the pawn contributes directly to the navmesh generation, its movement capability on said mesh will be compromised surely. A bit like shooting oneself in the foot.

Not sure if there’s a good way around it.

This works kinda well. But ill see it the long run if it affects the game performance.
image
I did that in the EventTick of the Character:

And it works. The character does not lose it way and go crazy but it still recognizes the non moving characters as obstacles.

But like i said : I see in the future if it is a good solution.

Thanks for the update!

For smaller humanoid like pawns that move around a bunch, might want to check out the avoidance options

Updating the nav mesh itself can be rather slow if you have a pack of enemies on screen trying to swarm the player, and a blob of them near each other will kinda just punch a large hole in the nav mesh around them so they all get stuck.

For larger/slower entities like a huge boss monster or something, AffectNavigation is probably fine though.

1 Like