Navhmesh for Custom Actors only?

Good afternoon guys,

After a while being inactive, today I got a small idea, but in order for it to become true, the following needs to be achievable:

  • Is it possible to make the navmesh ignore certain meshes/actors, or simply, to work only on a set of desirable actor classes? Even better if it could be changeable on runtime, from the default method to the custom one.

In practice, the navmesh doesn’t need to be re-generated, but the behaviour tree (or w/e its called, haven’t messed around with it to be honest) should only look at the desired objects. Or alternatively, have two or three navmeshes depending on what one needs.

Can Ever Affect Navigation

Dear Horus,

You can set the bool CanEverAffectNavigation in C++ or in BP to make any instances of actors, or whole classes of actors by setting in defaults, be ignored by Collision System!

(most fundamental collision class)

	/** Can this component potentially influence navigation */
	bool CanEverAffectNavigation() const
		return **bCanEverAffectNavigation**;

	/** set value of bCanEverAffectNavigation flag and update navigation octree if needed */
	void **SetCanEverAffectNavigation**(bool bRelevant);


/** Check if owned component should be relevant for navigation
	 *  Allows implementing master switch to disable e.g. collision export in projectiles
	virtual bool IsComponentRelevantForNavigation(UActorComponent* Component) const { return true; }

So you’d set the bool to false on all the colliding components of the actors you want to be ignored by the navigation system.

**Rebuild At Runtime, Change CanEverAffectNavigation Dynamically!**

If you go to **Project Settings->Nav Mesh** in the Editor

and make **Rebuild at Runtime** active, then you can change an actor's participation in the nav mesh during runtime, because the nav mesh will rebuild each time you use **PrimitiveComponent::SetCanEverAffectNavigation**!

This allows you to easily decide at any time during the entire play time of your game whether or not an actor should affect nav mesh generation!



To be honest I was expecting you to reply, I knew you had the answer :smiley:

You’re a life saver mate, thank you!

Taken me 3 hours to find a solution that worked and failed each time till now. Thanks so much :slight_smile: