Search Unity

Question Freelook Camera orbit is jittery with all bindings but SimpleFollowWithWorldUp

Discussion in 'Cinemachine' started by Ninjuit, Mar 17, 2023.

  1. Ninjuit

    Ninjuit

    Joined:
    Jul 7, 2012
    Posts:
    9
    Hey yall!

    I have an issue with a Cinemachine Freelook camera where I'm trying to have my camera orbit it around a player that is updated in FixedUpdate while the player is moving. The camera only orbits on the horizontal axis (X axis in this case) and doesn't move on the vertical axis. I have found that w/ all permutations of FixedUpdate, LateUpdate, SmartUpdate, etc that either the orbital movement is very jittery or the camera stutters behind player movement like classic update step mismatching! I can never get both to be smooth.

    However! If I use the binding SimpleFollowWithWorldUp I can get perfectly smooth motion in all circumstances. I have no idea why, but that binding comes with other undesirable behaviors such as the camera reorienting to the target forward over time and it being difficult (impossible?) to smoothly (or instantly) recenter the camera behind the player with code.

    I am trying to figure out how to set up this camera correctly to get smooth orbital rotation while the player is moving. For example, in a typical 3D platformer.

    Assumptions for you to make:
    • My character is using a Rigidbody and is properly being updated in FixedUpdate. I have created a separate character controller to test this away from my more complicated one.
    • I am using a separate script to rotate the camera around the player by changing the vCam.m_XAxis.Value in FixedUpdate. This script lives on the vCam and doesn't touch the actual camera.
    • It would be challenging to change from the Freelook Camera to some other Cinemachine Camera type because there are assumptions throughout the codebase that rely on this.
    • I'm open to changing the camera type only as a last resort!
    • I can't share the project, but I can answer questions and provide example code.
    Hoping someone can help!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Would you be willing to set up a small test project that shows this behaviour? Likely the problem stems from some interplay between your character controller and the camera system. If you would send me a test project we could solve this very quickly.
     
  3. Ninjuit

    Ninjuit

    Joined:
    Jul 7, 2012
    Posts:
    9
    Hey Gregoryl,

    I spent an hour or so setting up a test project and it doesn't seem to exhibit the same issue. But there's a problem...

    I made sure to create two scenes using the exact same scripts, map layout, cinemachine rigs (basically I exported a package and imported it into a new project) and it jitters in the original project and is fine in the test one. The only difference of note between both projects is the materials being used on the objects.

    Both are running at 60fps. Both have the same physics player settings!

    I've uploaded two videos showing this!

    Do you have any thoughts? Or leads you think I could run down?
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    I'd be very surprised if it's related to the materials. There must be something else going on. Would you be willing to send me the project that shows the problem?

    It could have something to do with script execution order or time settings.

    What if you copied the project settings from the original project and put them into the test project?