mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
sync rotation too
This commit is contained in:
parent
da1c247a73
commit
29bb6ef399
@ -40,6 +40,7 @@ protected override void OnValidate()
|
||||
public override void OnSerialize(NetworkWriter writer, bool initialState)
|
||||
{
|
||||
writer.WriteVector3(rb.position);
|
||||
writer.WriteQuaternion(rb.rotation);
|
||||
writer.WriteVector3(rb.velocity);
|
||||
}
|
||||
|
||||
@ -47,13 +48,15 @@ public override void OnSerialize(NetworkWriter writer, bool initialState)
|
||||
// this is where reconciliation happens if necessary.
|
||||
public override void OnDeserialize(NetworkReader reader, bool initialState)
|
||||
{
|
||||
double timestamp = NetworkClient.connection.remoteTimeStamp;
|
||||
Vector3 position = reader.ReadVector3();
|
||||
Vector3 velocity = reader.ReadVector3();
|
||||
double timestamp = NetworkClient.connection.remoteTimeStamp;
|
||||
Vector3 position = reader.ReadVector3();
|
||||
Quaternion rotation = reader.ReadQuaternion();
|
||||
Vector3 velocity = reader.ReadVector3();
|
||||
|
||||
// hard force for now.
|
||||
// TODO compare past position at timestamp, and only correct if needed
|
||||
rb.position = position;
|
||||
rb.rotation = rotation;
|
||||
rb.velocity = velocity;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user