mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-07 13:05:41 +00:00
13f5e2ebc3
- spawn authqueue objects with no authority for real instead of with server authority
39 lines
925 B
C#
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();
|
|
}
|
|
}
|
|
}
|