Search Unity

Cinemachine Collider is stuttering when colliding with kinematic interpolated rigidbody

Discussion in 'Cinemachine' started by edsonnnn, Apr 28, 2022.

  1. edsonnnn

    edsonnnn

    Joined:
    Jun 1, 2021
    Posts:
    14
    When the Cinemachine Collider is enabled and the camera is colliding with an interpolated kinematic rigidbody, the camera stutters a lot.

    How to replicate:
    Create a new 2021.2.17f1 URP project. (EDIT: or 2021.3.1f1 LTS, same problem)
    Install Cinemachine 2.8.4, then import Cinemachine Example Scenes.
    Open the 3rdPersonWithAimMode.unity scene.
    Drag a cube into the scene, add rigidbody to it, enable interpolation, add this script to it: https://docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html.

    When the rotating cube rotates into the camera the camera is being moved by the rigidbody as expected, but it causes stuttering.

    Is there any way to fix this? The rigidbody is being updated in fixedUpdate. I have tried all update methods available in CinemachineBrain, and tried many other things. But I can't get it to work. Any help is greatly appreciated.

    Edit: increasing the damping on the Cinemachine Collider fixes the stutters, but then it always clips throught the wall first, which is a big problem for this game
     
    Last edited: Apr 28, 2022
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I'm not able to reproduce this issue. I don't see any stuttering when I set up a scene as you describe. If you'd like to prepare a project and send it to me, I can have a look at it.

    One thought: the 3rdPersonWithAimMode scene is set up to run in FixedUpdate, so it's possible that interpolated objects don't always play nicely with it.
     
  3. edsonnnn

    edsonnnn

    Joined:
    Jun 1, 2021
    Posts:
    14
    Last edited: May 12, 2022
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Thank you for the videos and the project. I can see the issue.

    CM collider works by doing raycasts with the physics system. Unfortunately, raycasts work on the uninterpolated physics world. There is no way to do raycasts on the interpolated objects, so CM can't fix this.

    Your best bet might be to put the smallest amount of damping on the collider that you are willing to live with that fixes the jitter.