Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Kinematica: Inconsistent delta time reported when rewinding in snapshot debugger

Discussion in 'Animation Previews' started by randomPoison, Apr 23, 2021.

  1. randomPoison

    randomPoison

    Joined:
    Apr 3, 2021
    Posts:
    5
    When rewinding with the snapshot debugger,
    Debugger.instance.deltaTime
    will have an inaccurate value on the first frame after scrubbing the debugger to a new recorded frame. This results in a noticeable jitter when scrubbing the debugger between frames with a large difference in delta times:

    snapshot-debugger-jitter.gif

    This can be reproduced consistently with the following steps:
    1. Enter play mode.
    2. In the snapshot debugger window, begin recording.
    3. Record at least a few seconds of animation data (i.e. where at least one character is animating through Kinematica).
    4. Pause the snapshot debugger (either by pressing "pause recording" or by clicking on the snapshot debugger timeline).
    5. Slowly scrub through the snapshot debugger until you notice a frame that jitters visibly when you scrub to it.
    6. Set the debug timeline to just before the frame that has the jitter.
    7. Pause the editor.
    8. Set the debug timeline to the frame that has the jitter.
    9. Hit the next frame button (i.e. the one to the right of the pause button).
    10. Hit the next frame button again.
    Here you'll see that the first execution of the recorded frame produces slightly different results than all subsequent frames.

    In debugging this issue, it looks like the problem is that
    Debugger.instance.deltaTime
    will still have the value from the last-simulated frame when
    OnEarlyUpdate()
    , which is the point at which the
    Kinematica
    component stores the delta time for use by the synthesizer. Internally,
    Debugger
    restores the recorded snapshot in
    OnPreUpdate()
    , which is called after
    OnEarlyUpdate()
    , which means that
    Kinematica
    (and consequently the synthesizer) doesn't have the correct delta time until the second time a recorded frame is run.

    It's unclear to me what the correct fix here is. It's possible that
    Debugger
    needs to be updated to restore the snapshot in
    OnEarlyUpdate()
    , that way all code for the simulated frame is correctly synced. If I can, I'd like to find a workaround for this that doesn't involve modifying the Kinematica source code, that way anybody else working with Kinematica 0.8 during the hiatus can also make use of it. Will update if I figure anything out.
     
  2. april_4_short

    april_4_short

    Joined:
    Jul 19, 2021
    Posts:
    489
    cc @Tautvydas-Zilys

    Does this look like something your wisdom and insights can provide wisdom and insight about?
     
  3. randomPoison

    randomPoison

    Joined:
    Apr 3, 2021
    Posts:
    5