25 lines
818 B
C#
25 lines
818 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace NeonTea.Quakeball.Util {
|
|
/// <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>
|
|
public class DesyncLerper : MonoBehaviour {
|
|
public float Speed = 1;
|
|
|
|
private Vector3 OriginalLocalPosition;
|
|
|
|
public void Offset(Vector3 offset) {
|
|
transform.position += offset;
|
|
}
|
|
|
|
private void Awake() {
|
|
OriginalLocalPosition = transform.localPosition;
|
|
}
|
|
|
|
private void Update() {
|
|
transform.localPosition = Vector3.Lerp(transform.localPosition, OriginalLocalPosition, Speed * Time.deltaTime);
|
|
}
|
|
}
|
|
}
|