NavMeshAgent对象.Warp(Vector3 目标点) 使角色瞬移到目标点。
NavMeshAgent.Warp public bool Warp (Vector3 newPosition); 参数 newPosition 将代理调整至的新位置。 返回 bool 如果成功调整了代理,返回 true,否则返回 false。 描述 将代理调整至指定的位置。 如果成功,返回 true,否则返回 false。 版权所有 © 2019 Unity Technologies. Publication 2019.1 教程社区答案...
NavMeshAgent.Warp Other Versions Leave feedback public bool Warp(Vector3 newPosition); Parameters newPosition New position to warp the agent to. Returns bool True if agent is successfully warped, otherwise false. Description Warps agent to the provided position. Returns true if successful, ...
自己的游戏中是使用agent获取目标速度, 然后根据动画root motion更新GameObject位置.获取速度并旋转物体朝向的代码如下 public Vector2 GetDirToPosbyNav(Vector3 pos) { Vector2 dir = Vector2.zero; if (!nav.isOnNavMesh) { nav.Warp(new Vector3(Position.x, 0f, Position.z)); ...
Warp Warps agent to the provided position. Inherited Members Properties PropertyDescription enabled Enabled Behaviours are Updated, disabled Behaviours are not. isActiveAndEnabled Reports whether a GameObject and its associated Behaviour is active and enabled. gameObject The game object this component is ...
指定一段新路径给代理。 如果指定路径成功代理会重新朝着新目标移动。如果指定失败路径被清空。 Stop 类型:void Stop() 停止代理沿着当前路径移动。 Warp 类型:bool Warp(Vector3 newPosition) (好像是直接让代理移动到指定的newPosition,之后代理不做任何移动)。
nav.isOnNavMesh) { nav.Warp(new Vector3(Position.x, 0f, Position.z)); return ...
NavMeshAgent.speed 速度 NavMeshAgent.steeringTarget 转向目标 NavMeshAgent.Stop 刹车 NavMeshAgent.stoppingDistance 刹车距离 NavMeshAgent.updatePosition 更新位置 NavMeshAgent.updateRotation 更新旋转 NavMeshAgent.velocity 速度 NavMeshAgent.Warp 弯曲
原因:导航NavMeshAgent组件所在物体距离Navmesh导航网格太远,'NavMeshAgent.SetDestination'设置导航目标点失败 解决:在设置导航目标点之前,可以用‘ NavMeshAgent.isOnNavMesh’判断,在返回值为Ture后再'NavMeshAgent.SetDestination',如果返回值为False,说明当前NavMeshAgent不在导航网格上,可用‘NavMeshAgent.Warp’纠正...