From 17a7cb70ed4000fa5b55076a1c174b86751c250c Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 9 Nov 2016 19:58:05 +0200 Subject: [PATCH] Resetting character position to the server pos if the difference between the positions is large enough --- Subsurface/Source/Characters/Animation/Ragdoll.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index cf5c0f741..486b072a9 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -1077,7 +1077,16 @@ namespace Barotrauma Vector2 positionError = serverPos.Position - localPos.Position; - if (positionError.Length() > collider.LinearVelocity.Length()+0.02f) + float errorMagnitude = positionError.Length(); + + if (errorMagnitude > 2.0f) + { + //predicted position was way off, reset completely + collider.SetTransform(serverPos.Position, collider.Rotation); + //local positions are incorrect now -> just clear the list + character.MemLocalPos.Clear(); + } + else if (errorMagnitude > collider.LinearVelocity.Length()/10.0f + 0.02f) { //our prediction differs from the server position //-> we need to move the saved local position and all the positions saved after it