mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
Predicted Billiards: fix Rigidbody access for latest prediction
This commit is contained in:
parent
8334f3549c
commit
e564ff92d0
@ -45,12 +45,17 @@ void ApplyForceToWhite(Vector3 force)
|
|||||||
// https://docs.unity3d.com/2021.3/Documentation/ScriptReference/Rigidbody.AddForce.html
|
// https://docs.unity3d.com/2021.3/Documentation/ScriptReference/Rigidbody.AddForce.html
|
||||||
// this is buffered until the next FixedUpdate.
|
// this is buffered until the next FixedUpdate.
|
||||||
|
|
||||||
|
// get the white ball's Rigidbody.
|
||||||
|
// prediction sometimes moves this out of the object for a while,
|
||||||
|
// so we need to grab it this way:
|
||||||
|
Rigidbody rb = whiteBall.GetComponent<PredictedRigidbody>().predictedRigidbody;
|
||||||
|
|
||||||
// AddForce has different force modes, see this excellent diagram:
|
// AddForce has different force modes, see this excellent diagram:
|
||||||
// https://www.reddit.com/r/Unity3D/comments/psukm1/know_the_difference_between_forcemodes_a_little/
|
// https://www.reddit.com/r/Unity3D/comments/psukm1/know_the_difference_between_forcemodes_a_little/
|
||||||
// for prediction it's extremely important(!) to apply the correct mode:
|
// for prediction it's extremely important(!) to apply the correct mode:
|
||||||
// 'Force' makes server & client drift significantly here
|
// 'Force' makes server & client drift significantly here
|
||||||
// 'Impulse' is correct usage with significantly less drift
|
// 'Impulse' is correct usage with significantly less drift
|
||||||
whiteBall.GetComponent<Rigidbody>().AddForce(force, ForceMode.Impulse);
|
rb.AddForce(force, ForceMode.Impulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when the local player dragged the white ball.
|
// called when the local player dragged the white ball.
|
||||||
|
Loading…
Reference in New Issue
Block a user