Search Unity

Question Top down view around a sphere jitters

Discussion in 'Cinemachine' started by sixfyii, Sep 9, 2022.

  1. sixfyii

    sixfyii

    Joined:
    Jun 14, 2022
    Posts:
    3
    I'm attempting to use a Cinemachine virtual camera to follow a player around a spherical object with a top down view, for the most part things work with `Frame Transposer` for the body and `Composer` for the aim but there's always a slight jitter. Changing to use `Hard Look At` for the aim increases the jitter even more, as it's around a sphere I can't use `Do Nothing` for the aim. I can decrease the jitter by increasing the damping on X/Y/Z but it's still there especially when the player and camera do a full loop of the sphere.

    I've been able to script a normal Unity camera to follow the player around a sphere smoothly, but I was hoping to rely on Cinemachine to do the work for me (mostly so I can use the extensions).

    Cinemachine Brain is set to `Smart Update`, though trying others such as `Late Update` still has the problem. My player moves by setting `transform.position` during `Update`. Unsure if it's down to the way my player is moving as if I update the player speed, then the jittering becomes much more noticeable (whilst still using `Frame Transposer` and `Composer`).

    Any idea's on why the jitter occurs? I feel like I've tried every option and had no luck, perhaps moving a virtual camera around a sphere is not something Cinemachine is able to cope with or most likely I've missed some combination.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    It would help to show a video so that we can understand the nature of the jitter. There are many different possible artifacts that can be described as "jitter".

    If the player's transform is being changed exclusively in Update, then setting the Brain to LateUpdate or SmartUpdate will be correct.

    One thing to understand: Composer and HardLookAt are both susceptible to gimbal lock if the camera forward vector wants to be parallel to the up axis. One way around this is to use a travelling up. Since you have a top-down view (you didn't mention whether there is some obliqueness or if it is pure top-down), you can do this by making an invisible child of the player, rotated so that its local up is pointing forward, and using that object in the brain's World Up Override field.
     
    Last edited: Sep 12, 2022
  3. sixfyii

    sixfyii

    Joined:
    Jun 14, 2022
    Posts:
    3
    The jitter depends on which options on the virtual camera are used, the worst (using `Hard Look At`) has the camera spinning as the player moves, it's not as bad when using `Composer` but definitely far from usable.

    Transposer + Hard Look At: https://youtube.com/shorts/P-UY1Uwa5Gc
    Transposer + Composer: https://youtube.com/shorts/0wA38X7GXRY

    The best I had it last week (can't quite remember the settings) so can't take a video, made it look like the camera wasn't updating fast enough, it would keep jumping to keep the player in the middle and then drift away from that, and keep repeating. I've tried using an invisible object that is rotated to point it's up axis forward, however that has the same issue, either the camera is completely glitching or it jitters.

    Using the virtual camera and my own movement script (with body and aim set to `Do Nothing`) seems to be the only solution. This is fine for me, I can still use the virtual camera's features and extensions with my own movement + rotation script so the problem is solved, it does seem like there's a couple of bugs in Cinemachine though when following a spherical object.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for the videos. What version of Cinemachine are you using? Are you willing to share with me a test project that shows this problem?
     
  5. sixfyii

    sixfyii

    Joined:
    Jun 14, 2022
    Posts:
    3
    Cinemachine 2.8.9, I can put together a test project over the next few days. Is it okay to send it you in a DM?
     
    Gregoryl likes this.
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, a DM is fine. If you're sending a zipfile, be sure to delete the Library folder before zipping. It's huge and Unity can regenerate it when the project is opened.