only update transform from host after receiving the transform, instead of every frame

This commit is contained in:
JohnCorby 2021-11-13 19:42:39 -08:00
parent 9892ebe07f
commit 157cc185da

View File

@ -3,7 +3,7 @@ using QSB.MeteorSync.WorldObjects;
using QSB.Syncs.Unsectored.Rigidbodies; using QSB.Syncs.Unsectored.Rigidbodies;
using QSB.Utility; using QSB.Utility;
using QSB.WorldSync; using QSB.WorldSync;
using UnityEngine; using QuantumUNET.Transport;
namespace QSB.MeteorSync.TransformSync namespace QSB.MeteorSync.TransformSync
{ {
@ -40,18 +40,30 @@ namespace QSB.MeteorSync.TransformSync
base.Init(); base.Init();
SetReferenceTransform(Locator._brittleHollow.transform); SetReferenceTransform(Locator._brittleHollow.transform);
}
DebugLog.DebugWrite($"{LogName} - init");
private bool _shouldUpdate;
public override void DeserializeTransform(QNetworkReader reader, bool initialState)
{
base.DeserializeTransform(reader, initialState);
_shouldUpdate = true;
} }
protected override bool UpdateTransform() protected override bool UpdateTransform()
{ {
// DebugLog.DebugWrite($"{LogName} - {Time.time - _lastClientSendTime}"); if (HasAuthority)
if (Time.time - _lastClientSendTime > GetNetworkSendInterval())
{ {
return base.UpdateTransform(); return base.UpdateTransform();
} }
return false;
if (!_shouldUpdate)
{
return false;
}
_shouldUpdate = false;
return base.UpdateTransform();
} }