NavMeshAgent

来源:互联网 发布:索尼变焦镜头知乎 编辑:程序博客网 时间:2024/05/17 03:48

1.Radius

给物体添加NavMeshAgent组件后,可以在场景中多了一个包围物体的一个圆柱体(cylinder).这个Radius就表示了这个圆柱体的半径。当然这是相对于物体的半径大小,而不是实际大小。

agent的躲避半径。在这个半径(圆柱体)范围内,别的agent和obstacle将无法通过。其中obstacle是指添加了Nav Mesh Obstacle组件的物体。

2.Speed

agent的最大速率,float类型的标量,而非矢量。

一般情况下,刚开始时,velocity为Vector3.zero,

在acceleration的作用下逐渐趋向于desiredvelocity,其大小逐渐增大至speed。达到speed后,就稳定在这个速率,在转弯或者接近终点时,速率才减小。

但是若路径太短,速率在还没有增大到speed时,就将要到达终点了,然后就开始减速了,所以速率不会达到speed。

3.Acceleration

最大加速度

The maximum acceleration of an agent as it follows a path, given in units / sec^2.

An agent does not follow precisely the line segments of the path calculated by the navigation system but rather uses the waypoints along the path as intermediate destinations. This value is the maximum amount by which the agent can accelerate while moving towards the next waypoint.

4.Angular Speed

最大角速度,指agent旋转时的角速度,单位为度每秒

Maximum turning speed in (deg/s) while following a path.

This is the maximum rate at which the agent can turn as it rounds the "corner" defined by a waypoint. The actual turning circle is also influenced by the speed of the agent on approach and also the maximum acceleration.

5.Stopping Distance

当agent与目标物的距离小于等于Stopping Distance时,agent开始减速,desierdvelocity为0,velocity开始减小

6.Auto Traverse Off Mesh Link

自动通过Off Mesh Link。若设置为false,则agent到达Off Mesh Link时,将无法通过。

7.Auto Braking

自动刹车,以避免agent冲过终点。

将Auto Braking设为false,并且使Stopping Distance较小时,我们可以看到,agent会在到达终点后继续运动(冲过终点),然后折返,如此往复。。。

8.

9.Height

圆柱体的高度

10.Base Offset

Vertical offset of the collision geometry relative to the actual geometry.

碰撞几何体(也就是圆柱体)的垂直偏移量,相对于实际几何体(模型)。

当Base Offset为0时,圆柱体的底面与物体的pivot point在同一水平面上。

11.Obstacle Avoidance Type

当Obstacle Avoidance Type为None时,别的agent和Obstacle将通过agent的圆柱范围。否则将无法通过。参见第一个属性Radius。

质量越好,性能消耗越大。

12.Avoidance Priority

躲避优先级

从0到99,低数值代表高优先级。

试验:

 (1)给角色添加NavMeshAgent,Avoidance Priority为默认的50。

 (2)设定目标位置。

 (3)给角色添加脚本,使角色寻路,观察角色此时行进的路径。

 (4)在预估的路径上放置一个障碍物,同样给这个障碍物上添加NavMeshAgent。

 (5)分别设置障碍物的Avoidance Priority为默认的51,50,49。观察角色的行为。

结果:

当障碍物的avoidancePriority为51(与角色相比具有低优先级)时,角色行进到障碍物(圆柱体范围)的边缘时,将推动障碍物运动,角色本身的行进路径与(3)中完全一致,就好像障碍物不存在一样。

当障碍物的avoidancePriority为50(与角色相比具有相同优先级)时,角色行进到障碍物(圆柱体范围)的边缘时,将有可能推动障碍物运动,也有可能推不动,与两者之间的半径有关。角色本身的行进路径将受到障碍物影响,与(3)不一致

当障碍物的avoidancePriority为49(与角色相比具有高优先级)时,角色行进到障碍物(圆柱体范围)的边缘时,障碍物将完全不动,角色本身的行进的路径将受到障碍物影响,与

(3)不一致

总结:当具有不同优先级的agent相遇时,低优先级的agent不会对高优先级产生影响,而高优先级的agent却有可能对低优先级产生影响

 13.NavMesh Walkable

agent可以通的NavMesh的层级。

注意,自动产生的off mesh link的层级为Jump

Specifies which NavMesh layers are passable (bitfield). Changing walkableMask will make the path stale (see isPathStale).

 

2 0
原创粉丝点击