unity3d calculatepath

NavMesh.CalculatePath

public static function CalculatePath( sourcePosition: Vector3, targetPosition: Vector3, areaMask: int, path: NavMeshPath): bool;

Parameters

sourcePositionThe initial position of the path requested.
targetPositionThe final position of the path requested.
areaMaskA bitfield mask specifying which NavMesh areas can be passed when calculating a path.
pathThe resulting path.

Returns

bool True if a either a complete or partial path is found and false otherwise.

Description

Calculate a path between two points and store the resulting path.

This function can be used to plan a path ahead of time to avoid a delay in gameplay when the path is needed. Another use is to check if a target position is reachable before moving the agent.

In contrast to NavMeshAgent.SetDestination, which is asyncronous call, this function calculates the path immeditely. This can be costly operation for very long paths and can cause hiccup in the frame rate. It is recommended to do only a few path finds per frame, for example when evaluating distances to cover points.

The returned path can be used to set the path for an agent using NavMeshAgent.SetPath. The agent needs to be close the starting point for the set path to work.


public function CalculatePath( targetPosition: Vector3, path: NavMeshPath): bool;

Parameters

targetPositionThe final position of the path requested.
pathThe resulting path.

Returns

bool True if a path is found.

Description

Calculate a path to a specified point and store the resulting path.

This function can be used to plan a path ahead of time to avoid a delayin gameplay when the path is needed. Another use is to check if a target position is reachable before moving the agent.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值