mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
configurable frames
This commit is contained in:
parent
6f9cac6013
commit
61b3f40e7e
@ -84,6 +84,8 @@ public class PredictedRigidbody : NetworkBehaviour
|
|||||||
[Header("Smoothing")]
|
[Header("Smoothing")]
|
||||||
[Tooltip("Configure how to apply the corrected state.")]
|
[Tooltip("Configure how to apply the corrected state.")]
|
||||||
public CorrectionMode correctionMode = CorrectionMode.Move;
|
public CorrectionMode correctionMode = CorrectionMode.Move;
|
||||||
|
[Range(1, 60)] // 0 would never correct, and too high would take too long. assuming 60 FPS, the limit here is 1 second
|
||||||
|
public int deltaCorrectionFrames = 10; // TODO depend on delta time / speed later in case frame rate varies
|
||||||
Vector3 deltaCorrection_Position = Vector3.zero;
|
Vector3 deltaCorrection_Position = Vector3.zero;
|
||||||
|
|
||||||
[Header("Debugging")]
|
[Header("Debugging")]
|
||||||
@ -138,9 +140,8 @@ void ApplyDeltaCorrection()
|
|||||||
if (deltaCorrection_Position != Vector3.zero)
|
if (deltaCorrection_Position != Vector3.zero)
|
||||||
{
|
{
|
||||||
// apply only a little bit each frame
|
// apply only a little bit each frame
|
||||||
// TODO don't hardcode the amount
|
// TODO depend on deltatime instead of hard frames
|
||||||
// TODO depend on deltatime?
|
Vector3 step = deltaCorrection_Position / deltaCorrectionFrames;
|
||||||
Vector3 step = deltaCorrection_Position / 10;
|
|
||||||
rb.MovePosition(rb.position + step);
|
rb.MovePosition(rb.position + step);
|
||||||
deltaCorrection_Position -= step;
|
deltaCorrection_Position -= step;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user