SectoredRigidbodySync: set transform.position to Vector3.zero if ReferenceTransform is null, like in SectoredTransformSync

This commit is contained in:
JohnCorby 2021-12-05 02:26:58 -08:00
parent 906c5448d2
commit 078ac3b863

View File

@ -94,10 +94,20 @@ namespace QSB.Syncs.Sectored.Rigidbodies
protected void SetValuesToSync()
{
transform.position = ReferenceTransform.EncodePos(AttachedObject.transform.position);
transform.rotation = ReferenceTransform.EncodeRot(AttachedObject.transform.rotation);
_relativeVelocity = ReferenceTransform.GetAttachedOWRigidbody().EncodeVel(((OWRigidbody)AttachedObject).GetVelocity(), AttachedObject.transform.position);
_relativeAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().EncodeAngVel(((OWRigidbody)AttachedObject).GetAngularVelocity());
if (ReferenceTransform != null)
{
transform.position = ReferenceTransform.EncodePos(AttachedObject.transform.position);
transform.rotation = ReferenceTransform.EncodeRot(AttachedObject.transform.rotation);
_relativeVelocity = ReferenceTransform.GetAttachedOWRigidbody().EncodeVel(((OWRigidbody)AttachedObject).GetVelocity(), AttachedObject.transform.position);
_relativeAngularVelocity = ReferenceTransform.GetAttachedOWRigidbody().EncodeAngVel(((OWRigidbody)AttachedObject).GetAngularVelocity());
}
else
{
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
_relativeVelocity = Vector3.zero;
_relativeAngularVelocity = Vector3.zero;
}
}
protected override bool UpdateTransform()