unity3d calculatepath
2015-07-15 12:01
1391 查看
NavMesh.CalculatePath
public static functionCalculatePath(sourcePosition:Vector3,targetPosition:
Vector3,areaMask: int,path:
NavMeshPath): bool;
Parameters
sourcePosition | The initial position of the path requested. |
targetPosition | The final position of the path requested. |
areaMask | A bitfield mask specifying which NavMesh areas can be passed when calculating a path. |
path | The 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.
NavMeshAgent.CalculatePath
Switch to Manualpublic function
CalculatePath(targetPosition:Vector3,path:
NavMeshPath): bool;
Parameters
targetPosition | The final position of the path requested. |
path | The 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.
相关文章推荐
- 火箭鼠激光版自动开关,换图,旋转
- Unity3D研究院之拓展系统自带组件的Inspector视图
- 利用Unity来实现插件开发
- Unity3d UnityEditor编辑器定制和开发插件
- Unity协程(Coroutine)原理深入剖析
- Unity3d-反编译C#和提取资源
- Unity3D研究之与根据动态的两个轨迹点绘制面详解
- Unity3D 游戏引擎之控制模型移动旋转与碰撞
- Unity3D研究之第一人称第三人称角色控制组件修改
- Unity3D开发:为地形添加水源和效果
- Unity3D开发:在Unity3D中创建一个山势地形图
- 实战Unity3D开发:从认识界面到游戏demo
- Unity3D基础知识梳理
- Unity3D开发:Unity3D中的脚本概述
- Unity 3D引擎:十大最火的插件推荐
- Unity3D与旋转相关的函数(C#)
- Unity3D中的C#事件
- 使用 Unity 和 C# 开发您的首个游戏
- Unity3D与VS2008结合,加快Unity3D C#开发
- Unity3D教程宝典之Web服务器篇