sourcePosition | The origin of the distance query. |
hit | Holds the properties of the resulting location. |
passableMask | A mask specifying which NavMesh layers can be passed when finding the nearest edge. |
Locate the closest NavMesh edge from a point on the NavMesh.
var mesh: NavMesh; var player: Transform; // Move a marker object to show a position of cover // that the player should head for. function IndicateCoverPosition() { var hit: NavMeshHit; if (mesh.FindClosestEdge(player.position, hit, -1)) { transform.position = hit.position; } }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public NavMesh mesh; public Transform player; void IndicateCoverPosition() { NavMeshHit hit; if (mesh.FindClosestEdge(player.position, out hit, -1)) transform.position = hit.position; } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): public mesh as NavMesh public player as Transform def IndicateCoverPosition() as void: hit as NavMeshHit if mesh.FindClosestEdge(player.position, , -1): transform.position = hit.position