mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
21 lines
542 B
C#
21 lines
542 B
C#
using QSB.Utility;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.Player;
|
|
|
|
[UsedInUnityProject]
|
|
public class RemotePlayerVelocity : MonoBehaviour
|
|
{
|
|
private Vector3 _prevRelPosition;
|
|
|
|
public Vector3 Velocity { get; private set; }
|
|
|
|
public void FixedUpdate()
|
|
{
|
|
var reference = Locator.GetCenterOfTheUniverse().GetStaticReferenceFrame().transform;
|
|
var currentRelPosition = reference.InverseTransformPoint(transform.position);
|
|
Velocity = (currentRelPosition - _prevRelPosition) / Time.fixedDeltaTime;
|
|
_prevRelPosition = currentRelPosition;
|
|
}
|
|
}
|