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.

Free Look camera "follow target" jitters

Discussion in 'Cinemachine' started by namcap, Mar 4, 2022.

  1. namcap

    namcap

    Joined:
    Jan 8, 2016
    Posts:
    47
    I'm creating a CinemachineFreeLook camera that follows and looks at the same target. I'm trying 3 different scenarios, and each of the 3 results in the target jittering. All movements of the target are done in LateUpdate and the CinemachineFreeLook has 0.5 damping on all axes.

    1. I move the target by altering `transform.position` (using WASD), but this causes the target to have noticeable jitter.

    2. I set the follow and look at targets to ObjectB that SmoothDamps to follow ObjectA, which is moved via WASD. This causes very bad jitter.

    3. I set the follow and look at targets to ObjectB that Vector3.Lerps to follow ObjectA, which is moved via WASD. This causes medium jitter.

    I'm aiming for a solution where I can use option 2 or 3, as I want to be able to teleport ObjectA and have the camera smoothly move over to it. If I don't have ObjectB, then when ObjectA moves long distances, the Cinemachine camera moves very quickly to the object, looking almost instantaneous. Increasing damping isn't an option, as I don't want that damping on the regular WASD movements.

    What is causing this jitter and what are ways to fix it? I've browsed through the other jitter threads on the forums, but they don't seem relevant to the way I'm trying to create this camera.

    I am trying to get a camera that works similarly to that in Triangle Strategy.

    Here is a sample project with the setup I'm using and the code to move the target objects.

    Thanks for any help!
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    For this kind of camera behaviour, use Framing Transposer in Body. The camera has a constant rotation, so you don't need an Aim behaviour. You can set a rotation on the vcam's transform directly.
     
  3. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    What update method are you using for moving the target (Update, FixedUpdate, LateUpdate)? On your CinemachineBrain (MainCamera->CinemachineBrain), what's your Update Method?
     
  4. namcap

    namcap

    Joined:
    Jan 8, 2016
    Posts:
    47
    I think the Orbital Transposer that I'm currently using makes more sense here. The camera rotation can be changed around the X or Y axes (which I'm not sure if the video shows near the timestamped link) when moving the joystick. It rotates around the "look at" target.

    I'm moving the target in "LateUpdate" and the Brain is on "Smart Update", which figures out to use "LateUpdate". I've also tried "LateUpdate" on the Brain, which gives the same result.

    I've similarly tried moving everything to "Update", but that also gives the same result.

    If you have time to check it out, the sample project I linked has the entire setup.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,331
    It jitters because your target movement code doesn't take Time.deltaTime into account. In Unity, deltaTime is variable - especially when running in the editor. You're assuming a constant 0.03 when instead you should be doing:
    Code (CSharp):
    1. target.transform.position += (moveX + moveZ).normalized * Time.deltaTime;
     
    antoinecharton and namcap like this.