diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs index 3c386fee5..d389620cd 100644 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs +++ b/Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs @@ -135,8 +135,7 @@ protected virtual void Start() // Set last position and rotation to current values // so we can calculate velocity and angular velocity. - lastPosition = target.position; - lastRotation = target.rotation; + target.GetPositionAndRotation(out lastPosition, out lastRotation); } protected virtual void Update() @@ -145,8 +144,7 @@ protected virtual void Update() if (target == null) target = transform; // Use global coordinates for velocity and angular velocity. - Vector3 pos = target.position; - Quaternion rot = target.rotation; + target.GetPositionAndRotation(out Vector3 pos, out Quaternion rot); // Update velocity and angular velocity velocity = (pos - lastPosition) / Time.deltaTime; @@ -412,8 +410,7 @@ public virtual void ResetState() if (target == null) target = transform; // Reset last position and rotation - lastPosition = target.position; - lastRotation = target.rotation; + target.GetPositionAndRotation(out lastPosition, out lastRotation); // Reset velocity / angular velocity velocity = Vector3.zero;