From 29bb6ef3993f200f3af72534d6687c47d61ecc07 Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 6 Sep 2023 11:00:38 +0200 Subject: [PATCH] sync rotation too --- .../Components/PredictedRigidbody/PredictedRigidbody.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs index c0f39d087..12292d748 100644 --- a/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs +++ b/Assets/Mirror/Components/PredictedRigidbody/PredictedRigidbody.cs @@ -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; } }