From c46f2684708cb68b68dd56b0f3af514acac82f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Wed, 28 Mar 2018 21:19:14 +0200 Subject: [PATCH] Improved the drift correction on the NetworkedNavMeshAgent --- MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs b/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs index d855ed0..1022c76 100644 --- a/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs +++ b/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs @@ -11,6 +11,9 @@ namespace MLAPI.MonoBehaviours.Prototyping public bool EnableProximity = false; public float ProximityRange = 50f; public float CorrectionDelay = 3f; + //TODO rephrase. + [Tooltip("Everytime a correction packet is recieved. This is the percentage (between 0 & 1) that we will move towards the goal.")] + public float DriftCorrectionPercentage = 0.1f; private static byte[] stateUpdateBuffer = new byte[36]; private static byte[] correctionBuffer = new byte[24]; @@ -153,7 +156,7 @@ namespace MLAPI.MonoBehaviours.Prototyping Vector3 position = new Vector3(xPos, yPos, zPos); agent.velocity = velocity; - agent.Warp(position); + agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage)); } } }