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 8ce1f706f8

View File

@ -1,9 +1,8 @@
using System.Collections.Generic;
using QSB.MeteorSync.WorldObjects;
using QSB.Syncs.Unsectored.Rigidbodies;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
using QuantumUNET.Transport;
namespace QSB.MeteorSync.TransformSync
{
@ -40,18 +39,30 @@ namespace QSB.MeteorSync.TransformSync
base.Init();
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()
{
// DebugLog.DebugWrite($"{LogName} - {Time.time - _lastClientSendTime}");
if (Time.time - _lastClientSendTime > GetNetworkSendInterval())
if (HasAuthority)
{
return base.UpdateTransform();
}
return false;
if (!_shouldUpdate)
{
return false;
}
_shouldUpdate = false;
return base.UpdateTransform();
}