encode position when changing reference

This commit is contained in:
Mister_Nebula 2021-07-09 15:02:56 +01:00
parent 5ccbc49603
commit 764fb59ffb
4 changed files with 18 additions and 4 deletions

View File

@ -171,9 +171,14 @@ namespace QSB.Syncs.RigidbodySync
return;
}
DebugLog.DebugWrite($"{GetType().Name} set reference transform to {transform.name}");
ReferenceTransform = transform;
_intermediaryTransform.SetReferenceTransform(transform);
if (HasAuthority || NetIdentity.ClientAuthorityOwner == null)
{
_intermediaryTransform.EncodePosition(AttachedObject.transform.position);
_intermediaryTransform.EncodeRotation(AttachedObject.transform.rotation);
}
}
// TODO : optimize by using sqrMagnitude

View File

@ -183,7 +183,6 @@ namespace QSB.Syncs.TransformSync
return;
}
DebugLog.DebugWrite($"{_logName} set reference transform to {transform.name}");
ReferenceTransform = transform;
_intermediaryTransform.SetReferenceTransform(transform);
if (AttachedObject == null)
@ -199,6 +198,12 @@ namespace QSB.Syncs.TransformSync
{
ReparentAttachedObject(transform);
}
if (HasAuthority || NetIdentity.ClientAuthorityOwner == null)
{
_intermediaryTransform.EncodePosition(AttachedObject.transform.position);
_intermediaryTransform.EncodeRotation(AttachedObject.transform.rotation);
}
}
private void ReparentAttachedObject(Transform newParent)

View File

@ -121,7 +121,6 @@ namespace QSB.Syncs.TransformSync
public void SetReferenceSector(QSBSector sector)
{
DebugLog.DebugWrite($"{Player.PlayerId}.{GetType().Name} set reference sector to {sector.Name}");
ReferenceSector = sector;
SetReferenceTransform(sector?.Transform);
}

View File

@ -125,9 +125,14 @@ namespace QSB.Syncs.TransformSync
return;
}
DebugLog.DebugWrite($"{PlayerId}.{GetType().Name} set reference transform to {transform.name}");
ReferenceTransform = transform;
_intermediaryTransform.SetReferenceTransform(transform);
if (HasAuthority || NetIdentity.ClientAuthorityOwner == null)
{
_intermediaryTransform.EncodePosition(AttachedObject.transform.position);
_intermediaryTransform.EncodeRotation(AttachedObject.transform.rotation);
}
}
}
}