From d86b6c41ab5bbe926ffe88c09c05b2347b2e5ab7 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 7 Jun 2022 21:35:08 -0700 Subject: [PATCH] use SetPos/Rot to have suspended thing work --- .../TransformSync/ModelShipTransformSync.cs | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/QSB/ModelShip/TransformSync/ModelShipTransformSync.cs b/QSB/ModelShip/TransformSync/ModelShipTransformSync.cs index 9590418a..23c72c26 100644 --- a/QSB/ModelShip/TransformSync/ModelShipTransformSync.cs +++ b/QSB/ModelShip/TransformSync/ModelShipTransformSync.cs @@ -1,11 +1,6 @@ using QSB.Syncs.Sectored.Rigidbodies; -using QSB.Utility.LinkedWorldObject; +using QSB.Utility; using QSB.WorldSync; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace QSB.ModelShip.TransformSync; @@ -35,4 +30,29 @@ internal class ModelShipTransformSync : SectoredRigidbodySync SectorDetector.Init(modelShip.transform.Find("Detector").GetComponent()); return modelShip; } + + /// + /// replacement for base method + /// using SetPos/Rot instead of Move + /// + protected override void ApplyToAttached() + { + ApplyToSector(); + if (!ReferenceTransform) + { + return; + } + + var targetPos = ReferenceTransform.FromRelPos(SmoothPosition); + var targetRot = ReferenceTransform.FromRelRot(SmoothRotation); + + AttachedRigidbody.SetPosition(targetPos); + AttachedRigidbody.SetRotation(targetRot); + + var targetVelocity = ReferenceRigidbody.FromRelVel(Velocity, targetPos); + var targetAngularVelocity = ReferenceRigidbody.FromRelAngVel(AngularVelocity); + + AttachedRigidbody.SetVelocity(targetVelocity); + AttachedRigidbody.SetAngularVelocity(targetAngularVelocity); + } }