Search Unity

Need Help with Camera Jitter

Discussion in 'Game Design' started by Shadahan, Jan 15, 2022.

  1. Shadahan

    Shadahan

    Joined:
    Sep 14, 2015
    Posts:
    6
    So, I'm working on a 3D FPS controller.
    My first implementation was very stuttering, and I've read that it might be due to having implemented the character and the camera in different updates [ FixedUpdate(), Update() ].
    So this time, I've Implemented them both in Update() and although the jitter is reduced and inconsistent, it is still present.

    Please help me understand what could be the issue.
    I'll link my repo with the project.
    https://github.com/Shadahan/project_soft_bunny
     
  2. ZingZangGames

    ZingZangGames

    Joined:
    Dec 11, 2020
    Posts:
    73
    Try putting your controller into LateUpdate(), or SmartUpdate(). Would be nice if you post your scripts here if that first method didnt work.
     
  3. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    I can almost guarantee it’s an update issue as described above.

    Remember to do updates to physics on fixedupdate.

    And make sure you are multiplying by delta time when doing direct movements.
     
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    You can't just move stuff between Update() and FixedUpdate() and expect it to behave. You need to understand why they both exist in the first place, what's different about them, and what belongs where. For that, I recommend you start by reading the relevant sections of the manual, and the order of execution diagram. Then, once you understand what's going on, figure out the cause of your issues in that context.

    That said, there's a default model which may well solve your issue:
    - Make sure your character movement is implemented via the physics system. All code which directly modifies movement, position, etc. should be in FixedUpdate().
    - On your character's Rigidbody, ensure that the "Interpolate" property is set to the "Interpolate" value (it defaults to "None").
    - Make sure your camera does not have any physics (colliders, etc.) on it, is not a child of the character, and has its code implemented in LateUpdate() (or Update(), but not FixedUpdate()).

    Many issues that I see people have with camera stutter are that the first or third points aren't done correctly. They're messing with physics from the Update loop, or their camera's position is directly modified by something from the Physics system (FixedUpdate loop).

    The other thing that's also common is people not properly understanding when things should and should not be multiplied by the frame's time delta. I wouldn't call the usual results "jitter" but they definitely make your movement and/or camera feel all sorts of whacky.