mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
set Rigidbody position & rotation is safer
This commit is contained in:
parent
c3d2fac958
commit
89689359bf
@ -321,9 +321,9 @@ void FixedUpdateClient()
|
|||||||
// in theory we must always set rigidbody.position/rotation instead of transform:
|
// in theory we must always set rigidbody.position/rotation instead of transform:
|
||||||
// https://forum.unity.com/threads/how-expensive-is-physics-synctransforms.1366146/#post-9557491
|
// https://forum.unity.com/threads/how-expensive-is-physics-synctransforms.1366146/#post-9557491
|
||||||
// however, tf.SetPositionAndRotation is faster in our Prediction Benchmark.
|
// however, tf.SetPositionAndRotation is faster in our Prediction Benchmark.
|
||||||
// predictedRigidbody.position = newPosition;
|
predictedRigidbody.position = newPosition;
|
||||||
// predictedRigidbody.rotation = newRotation;
|
predictedRigidbody.rotation = newRotation;
|
||||||
tf.SetPositionAndRotation(newPosition, newRotation);
|
// tf.SetPositionAndRotation(newPosition, newRotation);
|
||||||
|
|
||||||
// transition to FOLLOWING after blending is done.
|
// transition to FOLLOWING after blending is done.
|
||||||
// we could check 'if p >= 1' but if the user's curve never
|
// we could check 'if p >= 1' but if the user's curve never
|
||||||
@ -360,7 +360,9 @@ void FixedUpdateClient()
|
|||||||
|
|
||||||
// interpolate & apply
|
// interpolate & apply
|
||||||
TransformSnapshot computed = TransformSnapshot.Interpolate(from, to, t);
|
TransformSnapshot computed = TransformSnapshot.Interpolate(from, to, t);
|
||||||
tf.SetPositionAndRotation(computed.position, computed.rotation); // scale is ignored
|
// tf.SetPositionAndRotation(computed.position, computed.rotation); // scale is ignored
|
||||||
|
predictedRigidbody.position = computed.position;
|
||||||
|
predictedRigidbody.rotation = computed.rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user