2020-08-08 03:17:54 +02:00
using System.Collections ;
using System.Collections.Generic ;
using UnityEngine ;
namespace NeonTea.Quakeball.Util {
2020-08-08 03:36:40 +02:00
/// <summary>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.</summary>
2020-08-08 03:17:54 +02:00
public class DesyncLerper : MonoBehaviour {
public float Speed = 1 ;
2020-08-08 03:36:40 +02:00
private Vector3 OriginalLocalPosition ;
2020-08-08 03:17:54 +02:00
public void Offset ( Vector3 offset ) {
transform . position + = offset ;
2020-08-08 03:36:40 +02:00
}
private void Awake ( ) {
OriginalLocalPosition = transform . localPosition ;
2020-08-08 03:17:54 +02:00
}
private void Update ( ) {
2020-08-08 03:36:40 +02:00
transform . localPosition = Vector3 . Lerp ( transform . localPosition , OriginalLocalPosition , Speed * Time . deltaTime ) ;
2020-08-08 03:17:54 +02:00
}
}
}