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

Question Inherit Position doesn't inherit rotation

Discussion in 'Cinemachine' started by NiftyParrot, Oct 25, 2021.

  1. NiftyParrot

    NiftyParrot

    Joined:
    Sep 17, 2017
    Posts:
    4
    This is my first time using Cinemachine, and this might be a pretty basic problem.
    I have a State Driven camera with two virtual child cameras, a FreeLook and a basic VCam. I want to toggle between the child cameras depending on a flag being set, and that's all working well and good in the State Driven camera.

    The problem is that I want the VCam to essentially freeze/disable the FreeLook camera and enable another set of mouse controls but when I transition, the VCam looks in the transform.forward direction instead of where the FreeLook is pointing. The InheritPosition property is enabled and the position of the FreeLook is maintained, just not the direction.

    57fc848c556a606593d8e6618fcf8b7d.png

    2cda99f4de4f048814bb41a1e03b04bc.png

    The documentation only mentions position but from what I've read from past threads, the Inherit Position property being enabled means the virtual camera should initialize both position and rotation to those of the virtual camera we just switched from. What's going wrong here? If inheriting rotation isn't intended behavior, could I use the axis values to derive where the VCam should be looking and do it programmatically?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    I just tried setting up what you describe. It works perfectly for me. Do you have some other logic that might be interfering? Try setting up this situation in an empty project to see if you can get the transitions to work.
     
  3. NiftyParrot

    NiftyParrot

    Joined:
    Sep 17, 2017
    Posts:
    4
    I tried making an entirely new project, stripped down to the basic elements but still see the same behavior. There is only one scripting element on the main camera, which is used to read mouse-click input to activate a boolean in the animator, nothing that should affect the camera rotation or the Cinemachine objects. The Cinemachine virtual cameras are using near-default settings, save for the Follow/Look At targets in the FreeLook and Inherit Position being enabled for both. I can't help but think it's something basic that I've overlooked.

    9cfa04fd825c4e1ffb1db10e19e514b0.png

    9d2a369ddf4b3801a44bd96578315e14.png

    4bb12843753af84f5776a9e5e54573e2.png
    1c20ced6627034716bce1fa48165e4aa.png

    4100665461233f6badaf93164c3a3036.png
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Can you send me the stripped-down project that shows the behaviour? Also please give me repro steps.
     
  5. NiftyParrot

    NiftyParrot

    Joined:
    Sep 17, 2017
    Posts:
    4
    Started with a 3D project, default scene. Installed and imported Cinemachine from the Unity Registry in the package manager. Created a cube in the scene to act as the target object.

    Instantiated a State Driven camera and a FreeLook Camera from the Cinemachine submenu, and parented the FreeLook to the State Driven camera in the object hierarchy. Set the Follow and Look At target in the FreeLook both to the cube object. Set one of the default VCam children to "Do nothing" with Body and Aim, and remove the other default VCam from the list. Enabled Inherit Position property on both virtual cameras.

    Created an Animator Controller with two states, the transitions triggered by a boolean that gets set to the opposite value with every right mouse click via the tiny script. Added the Animator and the script as components to the main camera, and used it as the animated target in the State Driven camera. Linked the FreeLook camera to the starting state in the State Driven camera, and the VCam with the other state.

    That's pretty much all the steps I took, top to bottom.
     

    Attached Files:

    • proj.zip
      File size:
      25.4 KB
      Views:
      253
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks for uploading.

    When I said "please give me repro steps", I meant "please give me the steps to see the problem in your project", and not "tell me what you did to create the project". But it's ok, I see the problem :)

    If you upgrade CM to 2.8.2, then the problem will be gone.
     
    NiftyParrot likes this.
  7. NiftyParrot

    NiftyParrot

    Joined:
    Sep 17, 2017
    Posts:
    4
    Sorry, I didn't know when the problem was coming in so I just posted all the steps I took.

    Updating seemed to work! I'll keep in mind that I might have to manually select versions other than the latest verified in the future. I appreciate the help.
     
  8. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    86
    I've just updated from 2.6.10 to 2.8.4 and I think this fix is actually impacting me negatively! I want to inherit the position, but NOT the rotation, there isn't a setting for this right now.

    Detail of my use case:
    - A main virtual camera follows the player (top down), updating the body/position... rotation is always the same
    - When a player dies, we enable a "game over" virtual camera gameObject with a higher priority, this one is about the same as the main camera, but the rotation is slightly different. (and some post effects are overriden)

    If I disable inherit position, the camera will be at 0,0,0 when it checks to blend, causing a camera glitch.

    edit: trying to reproduce this in a small project but not succesful yet, it could be some custom code interfering, will update when I find more.

    final edit: I found out why, the folllow target only gets enabled AFTER the blend starts in my case... I fixed this quite easily by setting this before the camera is enabled. However, it may still be a good idea to be able to seperate position & rotation inheriting in the future.
     
    Last edited: Jan 13, 2022