diff --git a/Assets/CustomNavMesh/Scripts/CustomNavMeshAgent.cs b/Assets/CustomNavMesh/Scripts/CustomNavMeshAgent.cs index f2d5202..c0ac212 100644 --- a/Assets/CustomNavMesh/Scripts/CustomNavMeshAgent.cs +++ b/Assets/CustomNavMesh/Scripts/CustomNavMeshAgent.cs @@ -358,6 +358,10 @@ NavMeshAgent NavMeshAgent public void Move(Vector3 offset) { if (NavMeshAgent.enabled) NavMeshAgent.Move(offset); + + // update hidden position now (instead of waiting for the next frame) + // so the agent's path can get recalculated sooner + if (HiddenAgent) HiddenAgent.transform.position = transform.position + CustomNavMesh.HiddenTranslation; } /// @@ -370,13 +374,19 @@ public void ResetPath() } /// - /// Warps agent to the provided position. + /// Warps agent to the provided position. If the agent has a path it will not be reset. /// /// New position to warp the agent to. /// True if agent is successfully warped, otherwise false. public bool Warp(Vector3 newPosition) { - return NavMeshAgent.Warp(newPosition); + bool result = NavMeshAgent.Warp(newPosition); + + // update hidden position now (instead of waiting for the next frame) + // so the agent's path can get recalculated sooner + if (HiddenAgent) HiddenAgent.transform.position = transform.position + CustomNavMesh.HiddenTranslation; + + return result; } ///