targetPosition | The final position of the path requested. |
path | The resulting path. |
Calculate a path to a specified point and store the resulting path.
var target: Transform; private var agent: NavMeshAgent; function Start () { agent = GetComponent.<NavMeshAgent>(); var path: NavMeshPath; agent.CalculatePath(target.position, path); if (path.status == NavMeshPathStatus.PathPartial) { // The target cannot be reached... } }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Transform target; private NavMeshAgent agent; void Start() { agent = GetComponent<NavMeshAgent>(); NavMeshPath path; agent.CalculatePath(target.position, path); if (path.status == NavMeshPathStatus.PathPartial) { } } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): public target as Transform private agent as NavMeshAgent def Start() as void: agent = GetComponent[of NavMeshAgent]() path as NavMeshPath agent.CalculatePath(target.position, path) if path.status == NavMeshPathStatus.PathPartial: pass