quantum-space-buddies/QSB/Syncs/QSBNetworkTransformChild.cs
JohnCorby 13f5e2ebc3 - no more initial state for qsb network behaviours because it is dumb and i hate it
- spawn authqueue objects with no authority for real instead of with server authority
2022-01-27 03:15:52 -08:00

39 lines
925 B
C#

using Mirror;
using QSB.Utility;
using UnityEngine;
namespace QSB.Syncs
{
public class QSBNetworkTransformChild : QSBNetworkBehaviour
{
public Transform Target;
protected override float SendInterval => 0.05f;
protected Vector3 _prevPosition;
protected Quaternion _prevRotation;
protected override void UpdatePrevData()
{
_prevPosition = Target.localPosition;
_prevRotation = Target.localRotation;
}
protected override bool HasChanged() =>
Vector3.Distance(Target.localPosition, _prevPosition) > 1E-05f ||
Quaternion.Angle(Target.localRotation, _prevRotation) > 1E-05f;
protected override void Serialize(NetworkWriter writer)
{
writer.Write(Target.localPosition);
writer.Write(Target.localRotation);
}
protected override void Deserialize(NetworkReader reader)
{
Target.localPosition = reader.ReadVector3();
Target.localRotation = reader.ReadQuaternion();
}
}
}