Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

NavMeshAgent.CompleteOffMeshLink

Suggest a change

Success!

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.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function CompleteOffMeshLink(): void;
public void CompleteOffMeshLink();
public def CompleteOffMeshLink() as void

Description

Follow 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()