Is it possible to change if a mesh affects nav mesh during run time

Hello

I have been having a problem trying to stop an object affecting the nav mesh while the game is running. I basically have a destructible mesh and want it to stop affecting the nav mesh once fractured, so that my AI can walk over the remains. It seems you can not change the bool for “Can ever affect navigation” through blueprint (None that I have found anyhow).
I would just like to know if it is possible to stop it affecting the nav mesh while in run time and how to do this?

Thank you in advance for any help and replies to this post.

Hello, warriorpin! I’ve stuck with same thing, have you figured it out?

Hi,

I found a way to change this bool at runtime. If you go ActorComponent.h, there is a method called SetCanEverAffectNavigation, just put a UFUNCTION(BlueprintCallable, Category=“Collision”) (This category allows you to find this method in blueprint collision category) on top of it to make it a UFUNCTION which can be called from blueprint. Recompile your engine after this change and it should work.

Cheers,

Yuchen

YuchenMei,
sorry I know this is a while ago, but could you guide me how to do this. Im quite new at C++ in UE4. I tried adding the code above in the line above SetCanEverAffectNavigation and rebuilding both the game and the engine but this didnt help anything.

Cheers,
Ben.

Ok, so in your blueprint, you should be able to call the function SetCanEverAffectNavigation and the target is the static mesh you want to change whether it affects the navigation. If you set the tCanEverAffectNavigation to false of the static mesh, it should stop this static mesh from affecting the navmesh.

Let me know if I am not explaining it well and it would be better to describe what you want to do more.

Cheers, Yuchen

Hi Yuchen,
Sorry i dont think i was clear. I want to be able to expose and call’SetCanEverAffectNavigation’ on static meshes spawned at runtime (which is currently not exposed in BP). These do not have this option at present, so how do you modify the C++ code in actorcomponent.h, because ive tried and it didnt seem to work (reading your post I assume you know how).

Cheers,
Ben.

EDIT: Okay, I found where to add the UFUNCTION line at and I’ve compiled just fine, but this still doesn’t show up in Blueprints. Can’t search, nor find it in the collisions section.

Any other steps we’re missing?

For Pawn, you can use function Set Can Affect Navigation. You should disable Context Sensitive in All Actions For Blueprint to find it.

For non Pawn actors, you can create NavLink and dynamically switch it.

Simplest method is to create Nav Modifier Volume with null and destroy it when destructible will be destroyed. I’m using mixed solutions depending on situation.

Well, this all is not need if you have dynamic Nav Mesh update on of course :slight_smile:

Thank you for all the alternate solutions. I found one that would work for my game using a modifier volume. Much simpler than the original solution proposed.

Thanks, btw those quotes give an error. Use regular quotes.
UFUNCTION(BlueprintCallable, Category = “Collision”)

I struggled with the same problem but found a nice workaround. You cannot change whether it affects navigation at runtime, BUT you can set “Can Ever Affect Navigation” to true, and then use “Set Collision Response to Chnnel” for Pawn and Vehicle collision channels to ignore/block depending on if you want to rebuild the navigation or not. If you set them to block then NavMesh’ll dynamically rebuild the navigation, if you set them to ignore the NavMesh somehow won’t detect them and won’t rebuild the navigation. Hope it helps.