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.
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?
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.
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.
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.
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.
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.
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.