use SetPos/Rot to have suspended thing work

This commit is contained in:
JohnCorby 2022-06-07 21:35:08 -07:00
parent e348efef88
commit d86b6c41ab

View File

@ -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<SectorDetector>());
return modelShip;
}
/// <summary>
/// replacement for base method
/// using SetPos/Rot instead of Move
/// </summary>
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);
}
}