From 5d8c1ece0b65479cf13bee1778fe92217982f230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Thu, 29 Mar 2018 01:28:45 +0200 Subject: [PATCH] Added WarpOnDestintionChange option to NetworkedNavMeshAgent --- MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs b/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs index 1022c76..6c12e43 100644 --- a/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs +++ b/MLAPI/MonoBehaviours/Prototyping/NetworkedNavMeshAgent.cs @@ -14,6 +14,7 @@ namespace MLAPI.MonoBehaviours.Prototyping //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; + public bool WarpOnDestinationChange = false; private static byte[] stateUpdateBuffer = new byte[36]; private static byte[] correctionBuffer = new byte[24]; @@ -133,7 +134,10 @@ namespace MLAPI.MonoBehaviours.Prototyping agent.SetDestination(destination); agent.velocity = velocity; - agent.Warp(position); + if (WarpOnDestinationChange) + agent.Warp(position); + else + agent.Warp(Vector3.Lerp(transform.position, position, DriftCorrectionPercentage)); } } }