A way to GetComponent of Nav Mesh Obstacle?

Hey,

I’m trying to find a way to enable/disable the nav mesh obstacle component on my object but after a bunch of google searching I’m unable to find an answer. Does Unity support this?

Thanks!

private void Start()
{
NavMeshObstacle NavMeshObstacle = GetComponent();
}

private void NMOEnable()
{
NavMeshObstacle.SetActive(true);
}

private void NMODisable()
{
NavMeshObstacle.SetActive(false);
}

Probably late to the party but I got stuck - you have to use the UnityEngine.AI namespace:

using UnityEngine.AI;

Then access the Component you want as you would expect:

NavMeshObstacle obstacle = object.GetComponent<NavMeshObstacle>();

Hope this helps!