Follow the current OffMeshLink.
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 Example : 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 Example(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()