From 80f2d1e6413bce6b30b9539a09600437153cedfa Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:03:50 -0400 Subject: [PATCH] Use GetPositionAndRotation --- .../Components/NetworkTransform/NetworkTransformBase.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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;