using System.Collections; 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. public class DesyncLerper : MonoBehaviour { public float Speed = 1; private Vector3 OffsetLeft; public void Offset(Vector3 offset) { transform.position += offset; OffsetLeft += offset; } private void Update() { Vector3 NewPosition = Vector3.Lerp(transform.position, transform.position - OffsetLeft, Speed * Time.deltaTime); OffsetLeft += NewPosition - transform.position; transform.position = NewPosition; } } }