Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Cinemachine Confiner with Ortho Camera looking at world obliquely: Jitters / Shakes at Corners

Discussion in 'Cinemachine' started by Jiaquarium, Mar 19, 2022.

  1. Jiaquarium

    Jiaquarium

    Joined:
    Mar 22, 2020
    Posts:
    45
    I'm wondering how to implement a confiner in a 3D world with an orthographic camera that is looking at the world obliquely from an angle.

    Here is a view from the Camera view angle. The yellow outlined box is the Bounding Volume (a skewed cube with a Mesh Collider) and the white outlined box is the camera viewport.



    From another angle (below):



    This works perfectly until the camera starts hitting the edges, particularly when it gets close to a corner the camera starts to jitter / shake.

    Why is the jitter / shake happening, is there something I'm missing?

    Thanks.
     
    Last edited: Mar 21, 2022
  2. Jiaquarium

    Jiaquarium

    Joined:
    Mar 22, 2020
    Posts:
    45
    It's seems like it might be just simpler to use the 2D Confiner. Through my testing this doesn't have any jitter with the skewed diamond-like Bounds.
     
    gaborkb likes this.
  3. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Jiaquarium likes this.
  4. Jiaquarium

    Jiaquarium

    Joined:
    Mar 22, 2020
    Posts:
    45
    Nice, it's very similar but our camera needs to be non-perspective.

    Thanks for the link, I'll check out the resources you provided in that post too.
     
  5. Jiaquarium

    Jiaquarium

    Joined:
    Mar 22, 2020
    Posts:
    45
    I tried the CinemachineConfiner2D extension (like in the Cinemachine Scene 2D Confiner in the examples), and once I try rotating the Camera it causes pretty bad jittering. I think most of my issues are coming from having to look at the world from an angle (above-right).

    The only way I can get it working is using the CinemachineConfiner extension (not 2D) with a 2D Polygon Collider that is also rotated along with the camera.

    The only drawback for this is you can't set "Confine Screen Edges" true or the jittering happens again, which would be nice to have since the game's ortho size can change.
     
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you send me a simplified project? I'd like to experiment with it, because it may be a use case we did not cover. :eek:
     
  7. Jiaquarium

    Jiaquarium

    Joined:
    Mar 22, 2020
    Posts:
    45
    Sure thing, just DMed you.

    Actually from more testing it seems I can't use 2D since I need the Z axis. It seems using an upright 3D bounding volume not facing the camera that sits above the plane actually works but there is a lot of trial-and-error.

    Using Confine Screen Edges this way though still sometimes jitters at the corners when the bounding volume has acute angles (like in the case of a skewed cube which I'm using for my bounding volumes).
     
    Last edited: Mar 22, 2022