Version: 2017.1

NavMeshAgent.ActivateCurrentOffMeshLink

切换到手册
public void ActivateCurrentOffMeshLink (bool activated);

参数

activated 链接是否已激活?

描述

启用或禁用当前的网格外链接。

此函数可激活或停用代理当前正在等待的网格外链接。 这可以用于 授予对游戏世界中新发现区域的访问权限或者 模拟一个区域的障碍物创建或清除。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private AI.NavMeshAgent agent; void Start() { agent = GetComponent<AI.NavMeshAgent>(); } void OpenDiscoveredArea(Hashtable areasDiscovered) { if (agent.isOnOffMeshLink) if (areasDiscovered.ContainsKey(agent.currentOffMeshLinkData.offMeshLink.name)) agent.ActivateCurrentOffMeshLink(true); } }