mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
PredictedRigidbody: OnDeserialize parsing grouped together (syntax change)
This commit is contained in:
parent
c503724b61
commit
597fd933c4
@ -769,10 +769,16 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
|
|||||||
// we want to know the time on the server when this was sent, which is remoteTimestamp.
|
// we want to know the time on the server when this was sent, which is remoteTimestamp.
|
||||||
double timestamp = NetworkClient.connection.remoteTimeStamp;
|
double timestamp = NetworkClient.connection.remoteTimeStamp;
|
||||||
|
|
||||||
// server send state at the end of the frame.
|
// parse state
|
||||||
|
double serverDeltaTime = reader.ReadFloat();
|
||||||
|
Vector3 position = reader.ReadVector3();
|
||||||
|
Quaternion rotation = reader.ReadQuaternion();
|
||||||
|
Vector3 velocity = reader.ReadVector3();
|
||||||
|
Vector3 angularVelocity = reader.ReadVector3();
|
||||||
|
|
||||||
|
// server sends state at the end of the frame.
|
||||||
// parse and apply the server's delta time to our timestamp.
|
// parse and apply the server's delta time to our timestamp.
|
||||||
// otherwise we see noticeable resets that seem off by one frame.
|
// otherwise we see noticeable resets that seem off by one frame.
|
||||||
double serverDeltaTime = reader.ReadFloat();
|
|
||||||
timestamp += serverDeltaTime;
|
timestamp += serverDeltaTime;
|
||||||
|
|
||||||
// however, adding yet one more frame delay gives much(!) better results.
|
// however, adding yet one more frame delay gives much(!) better results.
|
||||||
@ -781,12 +787,6 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
|
|||||||
// with physics happening at the end of the frame?
|
// with physics happening at the end of the frame?
|
||||||
if (oneFrameAhead) timestamp += serverDeltaTime;
|
if (oneFrameAhead) timestamp += serverDeltaTime;
|
||||||
|
|
||||||
// parse state
|
|
||||||
Vector3 position = reader.ReadVector3();
|
|
||||||
Quaternion rotation = reader.ReadQuaternion();
|
|
||||||
Vector3 velocity = reader.ReadVector3();
|
|
||||||
Vector3 angularVelocity = reader.ReadVector3();
|
|
||||||
|
|
||||||
// process received state
|
// process received state
|
||||||
OnReceivedState(timestamp, new RigidbodyState(timestamp, Vector3.zero, position, Quaternion.identity, rotation, Vector3.zero, velocity, Vector3.zero, angularVelocity));
|
OnReceivedState(timestamp, new RigidbodyState(timestamp, Vector3.zero, position, Quaternion.identity, rotation, Vector3.zero, velocity, Vector3.zero, angularVelocity));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user