Skip to content

Commit eb71ede

Browse files
committed
Fixed NavMeshAgent issue
Warping a navmeshagent resets it's destination. This behaviour is undocumented in the call, thus the warp now happends before the destination is set
1 parent 35a8ff1 commit eb71ede

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ private void OnNavMeshStateUpdate(uint clientId, BitReader reader)
158158
Vector3 velocity = new Vector3(xVel, yVel, zVel);
159159
Vector3 position = new Vector3(xPos, yPos, zPos);
160160

161-
agent.SetDestination(destination);
162-
agent.velocity = velocity;
163161
if (WarpOnDestinationChange)
164162
agent.Warp(position);
165163
else
166164
agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage));
165+
166+
agent.SetDestination(destination);
167+
agent.velocity = velocity;
167168
}
168169
}
169170
}
@@ -186,8 +187,8 @@ private void OnNavMeshCorrectionUpdate(uint clientId, BitReader reader)
186187
Vector3 velocity = new Vector3(xVel, yVel, zVel);
187188
Vector3 position = new Vector3(xPos, yPos, zPos);
188189

189-
agent.velocity = velocity;
190190
agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage));
191+
agent.velocity = velocity;
191192
}
192193
}
193194
}

0 commit comments

Comments
 (0)