Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Jitter problem for hero character with camera follow

Discussion in 'Physics' started by centaurianmudpig, Jul 8, 2022.

  1. centaurianmudpig

    centaurianmudpig

    Joined:
    Dec 16, 2011
    Posts:
    91
    Hello,

    I have a jitter problem with a large-sized model moving at fast speeds when interpolation is enabled for the hero character. It is important to have interpolation on to make the scene appear smoother, it's just the hero character jitters.

    I have a cinemachine camera set to follow, but with some testing, this appears more relevant to Unity/Physics than cinemachine itself.

    I have included an example project showing a follow object's jitter. It's a scaled cube but represents the actual size of the model with its colliders that I am using in my project that is scaled to 1,1,1. and jitters just as much.

    In the example project, I've made it as simple as I could, an initial force is applied to the ship and that's it. The ship then continues under its own momentum without any drag.

    Needs:
    • Camera to track the ship (player)
    • Interpolation enabled for the ship (player) for smoother camera movement of the game world.
    • Dampening on the camera is needed on the cinemachine camera for the ship to feel like it has weight in movement and rotation.
    • Appropriate sized models to maintain the weight of physics interactions of warship-sized ships
    Problem:
    Enabling interpolation causes the ship (player) to jitter while the camera moving around the game world appears smooth.
     

    Attached Files:

  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,019
    Just a hunch: scaling up an interpolated physics body will also scale the interpolation inaccuracy. This is similar to network prediction to compensate for lag.

    If someone confirms this the only solution I can think of would be to roll your own interpolation, or update fixed timestep to be in sync with frame updates.
     
  3. centaurianmudpig

    centaurianmudpig

    Joined:
    Dec 16, 2011
    Posts:
    91
    There is scaling in this repro, but no scaling in my project. If you replace the cube with a similar-sized model without scaling it still jitters.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    The test project works smoothly if you change the CMBrain's update mode from FixedUpdate to LateUpdate.
     
  5. centaurianmudpig

    centaurianmudpig

    Joined:
    Dec 16, 2011
    Posts:
    91