I’ve been trying to post this in the AnswerHub but I cannot log in at the moment, so apologies if this is not supposed to be here
I’ve got an environment build at run-time with a navmesh on top of it.
The project I’m working on requires LOTS of modifications to this environment at run-time so I started playing with this function
I call it whenever I modify the world providing the area to set as dirty, in the editor the green area representing the navmesh turns red when I call the method (thus signalling that it was actually marked as dirty, I guess…) but when the area turns green again no modifications are applied.
And yes, the geometry and the collisions have both been correctly (and visibly) modified.
The thing is that I’m not completely sure about the meaning of the Flags parameter to pass to the function; Digging around I found this definition:
enum Type
{
Geometry = (1 << 0),
DynamicModifier = (1 << 1),
UseAgentHeight = (1 << 2),
All = Geometry | DynamicModifier, // all rebuild steps here without additional flags
};
I’m currently using 3 which is “All” but it really doesn’t do anything!
You dont have to do anything in C++ to get the nav mesh to update properly!
Just go to
Project Settings->Navigation->Rebuild at runtime
It will always stay up to date
If you want to get really fancy change the update frequency to 1 instead of 60 in the other navigation category under Project Settings (Navigation System)!
Uhm, I have that checked but I’ve not tinkered with the value in the other window (60).
One thing that the editor lacks is the units of the various settings, it took me a while to understand that the recast values are in meters and not units
Just tried setting “Dirty Areas Update Freq” to 1: nothing.
Let me explain my situation a little bit better:
When I launch my game a terrain is generated and its geometry and collisions are added to the scene. I’ve got a big NavMeshBoundsVolume that wraps all the geometry and it correctly creates the navmesh from my geometry and collisions.
If, at run-time and after it was generated the first time, I do modify my terrain (by removing or adding geometry and collisions) the navmesh doesn’t update anymore.
I’ve also just noticed that if I move (Eject->Select the actor->Translate) the actor containing my terrain around, the navmesh DOES update around the new geometry.
“If, at run-time and after it was generated the first time, I do modify my terrain (by removing or adding geometry and collisions) the navmesh doesn’t update anymore.”
You have a much bigger problem!
You cannot modify landscapes at runtime in packaged games!
Or are you saying your terrain is made of static mesh actor pieces?
Have you tried packaging what you have so far?!
Epic has told me many times they are adding support for runtime collision cooking in packaged games soon
but you should make sure all your concepts are sound before proceeding any further,
and if you got runtime landscape collision generation to work please do let me know!
I think I have a series of HUGE problems to be honest.
I’ve been testing lots and lots of possible solutions to my current problems and nothing seems to work
Let me wrap them up:
I want to generate a “Minecraft-like” (not exactly the same, but it’s to give an idea) environment at run-time. I managed to generate the environment (thanks Rama for the wiki entry!) and it’s actually pretty fast, so I’m happy!
Now for the problems:
I want to be able to modify the environment, think about adding/subtracting blocks, to stick with the Minecraft analogy, I managed to do that, (again, pretty fast!) but the navmesh cannot be bothered and I cannot find a way to update it at run-time.
So I switched my focus to making some ACharacters move on top of my environment but they don’t want to do that. The same ACharacter (same blueprint) put on a static mesh runs around like Usain Bolt!
I’m pretty bored of attempts so I’ve got two questions:
Is it possible to modify the shape of a piece of geometry and have the navmesh update based on the new geometry?
Is it possible to use navmesh navigation using a navmesh COMPLETELY generated at run-time?