Skip to content

Commit 5d8c1ec

Browse files
committed
Added WarpOnDestintionChange option to NetworkedNavMeshAgent
1 parent 2442eab commit 5d8c1ec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class NetworkedNavMeshAgent : NetworkedBehaviour
1414
//TODO rephrase.
1515
[Tooltip("Everytime a correction packet is recieved. This is the percentage (between 0 & 1) that we will move towards the goal.")]
1616
public float DriftCorrectionPercentage = 0.1f;
17+
public bool WarpOnDestinationChange = false;
1718

1819
private static byte[] stateUpdateBuffer = new byte[36];
1920
private static byte[] correctionBuffer = new byte[24];
@@ -133,7 +134,10 @@ private void OnNavMeshStateUpdate(int clientId, byte[] data)
133134

134135
agent.SetDestination(destination);
135136
agent.velocity = velocity;
136-
agent.Warp(position);
137+
if (WarpOnDestinationChange)
138+
agent.Warp(position);
139+
else
140+
agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage));
137141
}
138142
}
139143
}

0 commit comments

Comments
 (0)