Version: 5.6
public bool FindClosestEdge (out AI.NavMeshHit hit);

パラメーター

hit 一番近い辺のヒット情報

戻り値

bool もっとも近い辺が見つかった場合は true

説明

もっとも近いナビメッシュの辺の位置を取得します

The returned NavMeshHit object contains the position and details of the nearest point on the nearest edge of the Navmesh. Since an edge typically corresponds to a wall or other large object, this could be used to make a character take cover as close to the wall as possible.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { private AI.NavMeshAgent agent; void Start() { agent = GetComponent<AI.NavMeshAgent>(); } void Update() { if (Input.GetMouseButtonDown(0)) TakeCover(); } void TakeCover() { AI.NavMeshHit hit; if (agent.FindClosestEdge(out hit)) agent.SetDestination(hit.position); } }