diff --git a/Assets/Scripts/Networking/Packets/PlayerActionPckt.cs.meta b/Assets/Scripts/Networking/Packets/PlayerActionPckt.cs.meta new file mode 100644 index 0000000..354943f --- /dev/null +++ b/Assets/Scripts/Networking/Packets/PlayerActionPckt.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ce4b9792bad15a54497d2a19cce83764 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Util/DesyncLerper.cs b/Assets/Scripts/Util/DesyncLerper.cs index 4344ac7..3f4bcd5 100644 --- a/Assets/Scripts/Util/DesyncLerper.cs +++ b/Assets/Scripts/Util/DesyncLerper.cs @@ -3,21 +3,22 @@ using System.Collections.Generic; using UnityEngine; namespace NeonTea.Quakeball.Util { - /// Used to offset visual parts of violently re-synced objects, so they can be smoothly lerped back to reality. + /// Used to offset visual parts of violently re-synced objects, so they can be smoothly lerped back to reality. This depends on the original localPosition staying the same. public class DesyncLerper : MonoBehaviour { public float Speed = 1; - private Vector3 OffsetLeft; + private Vector3 OriginalLocalPosition; public void Offset(Vector3 offset) { transform.position += offset; - OffsetLeft += offset; + } + + private void Awake() { + OriginalLocalPosition = transform.localPosition; } private void Update() { - Vector3 NewPosition = Vector3.Lerp(transform.position, transform.position - OffsetLeft, Speed * Time.deltaTime); - OffsetLeft += NewPosition - transform.position; - transform.position = NewPosition; + transform.localPosition = Vector3.Lerp(transform.localPosition, OriginalLocalPosition, Speed * Time.deltaTime); } } }