Question by
importguru88 · Aug 19, 2016 at 10:39 PM ·
navmeshnavmeshagentstop
How do I call Nav Mesh agent Stop
error CS0120: An object reference is required to access non-static member `UnityEngine.NavMeshAgent.Stop()'
I have a enemy ai using a nav mesh agent . I need to call a nav mesh agent stop . So I can stop the enemy ai from sliding toward the player. I check the unity3d docs. Did the code and it didn't work it gave me an error :
Here is my code :
NavMeshAgent.Stop();
Comment
Answer by Jessespike · Aug 20, 2016 at 03:15 AM
You need an object reference
NavMeshAgent agent = GetComponent<NavMeshAgent>();
agent.Stop();
agent is the object reference. This assumes NavMeshAgent is on the same GameObject as the code.