mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
save last deserialize position/rotation for delta
This commit is contained in:
parent
3242d84183
commit
44bbea507c
@ -58,7 +58,10 @@ public class NetworkTransformHybrid2022 : NetworkBehaviour
|
||||
Vector3 lastSerializedBaselinePosition = Vector3.zero;
|
||||
Quaternion lastSerializedBaselineRotation = Quaternion.identity;
|
||||
|
||||
// save last deserialized baseline to delta decompress against
|
||||
byte lastDeserializedBaselineTick = 0;
|
||||
Vector3 lastDeserializedBaselinePosition = Vector3.zero;
|
||||
Quaternion lastDeserializedBaselineRotation = Quaternion.identity;
|
||||
|
||||
// only sync when changed hack /////////////////////////////////////////
|
||||
[Header("Sync Only If Changed")]
|
||||
@ -212,6 +215,8 @@ bool Changed(Vector3 currentPosition, Quaternion currentRotation)//, Vector3 cur
|
||||
void CmdClientToServerBaseline_PositionRotation(byte baselineTick, Vector3 position, Quaternion rotation)
|
||||
{
|
||||
lastDeserializedBaselineTick = baselineTick;
|
||||
lastDeserializedBaselinePosition = position;
|
||||
lastDeserializedBaselineRotation = rotation;
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
@ -222,6 +227,7 @@ void CmdClientToServerBaseline_PositionRotation(byte baselineTick, Vector3 posit
|
||||
void CmdClientToServerBaseline_Position(byte baselineTick, Vector3 position)
|
||||
{
|
||||
lastDeserializedBaselineTick = baselineTick;
|
||||
lastDeserializedBaselinePosition = position;
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
@ -232,6 +238,7 @@ void CmdClientToServerBaseline_Position(byte baselineTick, Vector3 position)
|
||||
void CmdClientToServerBaseline_Rotation(byte baselineTick, Quaternion rotation)
|
||||
{
|
||||
lastDeserializedBaselineTick = baselineTick;
|
||||
lastDeserializedBaselineRotation = rotation;
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
@ -319,6 +326,8 @@ void RpcServerToClientBaseline_PositionRotation(byte baselineTick, Vector3 posit
|
||||
|
||||
// save last deserialized baseline tick number to compare deltas against
|
||||
lastDeserializedBaselineTick = baselineTick;
|
||||
lastDeserializedBaselinePosition = position;
|
||||
lastDeserializedBaselineRotation = rotation;
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
@ -334,6 +343,7 @@ void RpcServerToClientBaseline_Position(byte baselineTick, Vector3 position)
|
||||
|
||||
// save last deserialized baseline tick number to compare deltas against
|
||||
lastDeserializedBaselineTick = baselineTick;
|
||||
lastDeserializedBaselinePosition = position;
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
@ -349,6 +359,7 @@ void RpcServerToClientBaseline_Rotation(byte baselineTick, Quaternion rotation)
|
||||
|
||||
// save last deserialized baseline tick number to compare deltas against
|
||||
lastDeserializedBaselineTick = baselineTick;
|
||||
lastDeserializedBaselineRotation = rotation;
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
@ -1014,8 +1025,16 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
|
||||
Vector3 position = Vector3.zero;
|
||||
Quaternion rotation = Quaternion.identity;
|
||||
|
||||
if (syncPosition) position = reader.ReadVector3();
|
||||
if (syncRotation) rotation = reader.ReadQuaternion();
|
||||
if (syncPosition)
|
||||
{
|
||||
position = reader.ReadVector3();
|
||||
lastDeserializedBaselinePosition = position;
|
||||
}
|
||||
if (syncRotation)
|
||||
{
|
||||
rotation = reader.ReadQuaternion();
|
||||
lastDeserializedBaselineRotation = rotation;
|
||||
}
|
||||
|
||||
// if baseline counts as delta, insert it into snapshot buffer too
|
||||
if (baselineIsDelta)
|
||||
|
Loading…
Reference in New Issue
Block a user