Modify NavMeshBoundsVolume in C++

Hey guys,

I’ve got actors in my scene (spawned via C++) and I want to attach and modify NavMeshBoundsVolumes to them (also via C++).

 FActorSpawnParameters SpawnInfo;
 NaviMesh = GetWorld()->SpawnActor<ANavMeshBoundsVolume>(Super::GetActorLocation(), Super::GetActorRotation(), SpawnInfo);

Albeit the NavMesh is added to my scene, some problems occured in my attempts so far:

  • Mobility
    I’m not able to attach my static NavMesh to my movable Actor. How can I change its mobility? (SetMobility() doesn’t work). Currently I connect the NavMeshs via pointer to my actor class, but I bet there is a more elegant way :slight_smile:
  • Brush Shape
    The default brush shape of my spawned NavMesh is “None”, however I want the box shape (via CubeBuilder) to girdle my actor object. How can I change it via code?

Thanks in advance!

See those two Answers:

Thanks! Helped me a lot.
Nevertheless another problem - I’d like to attach my NavMesh to my actor (a spaceship). If I spawn the NavMesh in the spaceship constructor UE4 craches. Is it generally unlogical to attach a NavMesh to an actor? Seems to be programmed as an indepedent object in my level as MieszkoZ wrote in his answers.
My workflow so far will be to spawn the NavMesh during level load, independent from spaceship pawn.

To be Honest I dont know why you would ever need to attach a Navmesh to anything. If you just want to create a Navmesh around a Actor use Recast navmesh. Like showcased in the Deer Ai inside the Kite Demo take a look here: Creating the Open World Kite Real-Time Demo in UE4 | GDC 2015 Event Coverage | Unreal Engine - YouTube