A way to GetComponent of Nav Mesh Obstacle?


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?


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

private void NMOEnable()

private void NMODisable()

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!