Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFollow the current OffMeshLink.
When the autoTraverseOffMeshLink property is switched off an agent will pause at an off-mesh link until this function is called to let it pass. This can be used to allow characters access selectively (eg, to simulate openable doors or obstacles that only certain characters can pass, etc).
private var agent: NavMeshAgent; function Start () { agent = GetComponent.<NavMeshAgent>(); } // Let an agent cross the off-mesh link if he has // the right door key. function CheckForDoorKey(doorKeys: Hashtable) { if (agent.isOnOffMeshLink) { if (doorKeys.ContainsKey(agent.currentOffMeshLinkData.offMeshLink.name)) { agent.CompleteOffMeshLink(); } } }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { private NavMeshAgent agent; void Start() { agent = GetComponent<NavMeshAgent>(); } void CheckForDoorKey(Hashtable doorKeys) { if (agent.isOnOffMeshLink) if (doorKeys.ContainsKey(agent.currentOffMeshLinkData.offMeshLink.name)) agent.CompleteOffMeshLink(); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): private agent as NavMeshAgent def Start() as void: agent = GetComponent[of NavMeshAgent]() def CheckForDoorKey(doorKeys as Hashtable) as void: if agent.isOnOffMeshLink: if doorKeys.ContainsKey(agent.currentOffMeshLinkData.offMeshLink.name): agent.CompleteOffMeshLink()