2022-07-11 12:53:29 +00:00
|
|
|
|
using UnityEngine;
|
2022-04-10 20:19:21 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.Player;
|
|
|
|
|
|
|
|
|
|
public class RemotePlayerVelocity : MonoBehaviour
|
|
|
|
|
{
|
2022-07-11 12:53:29 +00:00
|
|
|
|
private Vector3 _prevRelPosition;
|
2022-04-10 20:19:21 +00:00
|
|
|
|
|
|
|
|
|
public Vector3 Velocity { get; private set; }
|
|
|
|
|
|
|
|
|
|
public void FixedUpdate()
|
|
|
|
|
{
|
2022-07-11 12:53:29 +00:00
|
|
|
|
var reference = Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().transform;
|
|
|
|
|
var currentRelPosition = reference.InverseTransformPoint(transform.position);
|
|
|
|
|
Velocity = (currentRelPosition - _prevRelPosition) / Time.fixedDeltaTime;
|
2022-07-11 17:02:06 +00:00
|
|
|
|
_prevRelPosition = currentRelPosition;
|
2022-04-10 20:19:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|