Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Issue of camera flipping/rotating during a blend

Discussion in 'Cinemachine' started by Pelican_7, Dec 4, 2018.

  1. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    127
    Hi all,

    I'm having an issue when blending between two cameras whereby my camera flips around to point in the opposite direction as it transitions over long distances. For example, in the video linked below, the first blend transition works well (short distance). In the second transition (medium distance), you can see the camera begin to rotate at the transition's midpoint. In the third transition (long distance), you can see the camera rotate backwards at the transition's midpoint.

    https://drive.google.com/open?id=1qS6-Hp4lcR5iG-Q_a_iWggfbxfGvmOSp

    My question is how can I prevent the camera from rotating like this during a blend so that all the transitions look like the first one?

    Some of my settings that may be relevant (?!):
    - I am using a Free Look Camera, transitioning into a Virtual Camera.
    - Both cameras have a Blend Hint of Spherical Position.
    - The Free Look camera has both a Follow transform and a Look At transform (which doesn't move during the transition).
    - The Free Look camera has its Heading Definition set to Target Forward.
    - The Free Look camera has all Aim rigs set to Hard Look At with no Look At Override.
    - The Virtual camera has a Look At target transform but no Follow transform.
    - The Virtual camera has its Aim set to Composer.

    What I have tried:
    - Adjusting the Blend Hint of both cameras (Spherical Position/Cylindrical Position). Whilst changing this setting does affect the transition somewhat, it still has the issue described above.
    - Using a Custom Blend asset on the Brain but this only appears to control the easing.

    Any advice is much appreciated, thanks!
    -andy.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,823
    It's always tricky to get a good blend when the LookAt target changes. Try setting the blend hint to this:

    upload_2018-12-4_17-31-17.png

    Also: what version of Cinemachine are you using?
     
  3. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    127
    Thanks for the response @Gregoryl.

    I get the same issue with the Screen Space Aim Blend Hint I'm afraid (I set it on both the Free Look cam and Virtual cam). I'm using Cinemachine v2.2.7 installed via the Package Manager in Unity 2018.3.0b12.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,823
    hmmm... this is puzzling. I'd like to try to repro this and see what's going on. Can you please post here:
    • the world positions of the 4 targets: initial, close, medium, and far
    • Inspectors for the FreeLook and the vcam, showing all relevant settings
    I will try to recreate this scenario with simple objects.
    Thanks
     
  5. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    127
    Ok great, thanks a lot @Gregoryl!

    Here are all the settings, let me know if you need anything else.

    Free Look Camera (Initial)
    Position: X: 0 Y: 170 Z: -130
    Rotation: X: 0 Y: 0 Z: 0

    Free Look Camera Settings

    FL1.PNG
    FL2.PNG

    The Follow and Look At transform of the Free Look Camera is a game object positioned at:

    Follow and Look At Transform
    Position: X: 0 Y: 40 Z: 0
    Rotation: X: 0 Y: 0 Z: 0

    The three Virtual Cameras that are transitioned to all have identical camera settings with one exception - their Look At transform. So I have included the position of each Virtual Camera's Look At transform too.

    Near Virtual Camera
    Position: X: 0 Y: 30 Z: -60
    Rotation: X: 30 Y: 0 Z: 0
    Look At Transform Position: X: 0 Y: 0 Z: 0

    Mid Virtual Camera
    Position: X: -150 Y: 30 Z: 140
    Rotation: X: 30 Y: 0 Z: 0
    Look At Transform Position: X: -150 Y: 0 Z: 200

    Far Virtual Camera
    Position: X: -300 Y: 30 Z: 340
    Rotation: X: 30 Y: 0 Z: 0
    Look At Transform Position: X: -300 Y: 0 Z: 400

    Virtual Camera Settings
    VC1.PNG

    -andy.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,823
    Thanks for that.

    I get the best results with Blend hint = None on the vcams, and blend hint = ScreenScreenSpaceAimWhenTrargetsDiffer on the FreeLook, and no InheritPosition on anything.

    What's happening is that the camera positions and lookAt targets are being lerped independently, and because of the layout of things, one passes by the other, causing the camera to swing.

    The only way, at present, to make that effect go away is to remove the LookAt target from the vcams, and just hardwire the vcam rotations, the same as you did for the positions. Without a LookAt target, the vcam will have no lookAt position to lerp, so it will have no choice but to slerp the rotations, which is what you're looking for, I think.
     
  7. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    127
    Ahh thanks a lot - removing the vcams LookAt target resolves the issue!

    I was using the Composer with a LookAt on the vcams so I could dynamically position the focal point in the left side of the screen with any aspect ratio (Screen X: 0.25), but without this I can still just about get away with having a fixed vcam lookAt rotation.

    Thanks so much for your help @Gregoryl – much appreciated!