mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
perf(PredictedRigidbody): OnSerialize faster
This commit is contained in:
parent
8e21a2101c
commit
1bd84f06d1
@ -637,9 +637,13 @@ public override void OnSerialize(NetworkWriter writer, bool initialState)
|
||||
// server is technically supposed to be at a fixed frame rate, but this can vary.
|
||||
// sending server's current deltaTime is the safest option.
|
||||
// client then applies it on top of remoteTimestamp.
|
||||
|
||||
|
||||
// FAST VERSION: this shows in profiler a lot, so cache EVERYTHING!
|
||||
tf.GetPositionAndRotation(out Vector3 position, out Quaternion rotation); // faster than tf.position + tf.rotation. server's rigidbody is on the same transform.
|
||||
writer.WriteFloat(Time.deltaTime);
|
||||
writer.WriteVector3(rb.position); // own rigidbody on server, it's never moved to physics copy
|
||||
writer.WriteQuaternion(rb.rotation); // own rigidbody on server, it's never moved to physics copy
|
||||
writer.WriteVector3(position);
|
||||
writer.WriteQuaternion(rotation);
|
||||
writer.WriteVector3(rb.velocity); // own rigidbody on server, it's never moved to physics copy
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user