I’m working on a top-down 2D game, and am trying to implement Cinemachine into the game. Previously I had a script which follows the character, but allows you to pan the camera around by holding the left mouse button and moving the cursor. When you let go of the mouse button, the camera tweens back to the character’s position.
How would you implement something like this with Cinemachine? While Cinemachine Brain is active the camera transforms cannot be moved manually, so it appears I’d need to do the panning through Cinemachine, but I can’t see how I would do this.
You would create a virtual camera that is controlled by the mouse position (set the Aim and Body both to “do nothing” and you can control its position/orientation manually). When the mouse button is pressed, enable this vcam; when it is released, disable it. Cinemachine will bend to/from this manual vcam according to your blend settings.
Thanks @Gregoryl this seems like it’ll work nicely.
I’ve got a ‘Character VC’ set to priority 10, and a ‘Pan VC’ set to priority 11. Blending between them seems to work if I keep them seperate, but if I put Pan VC as a child of Character VC then Pan VC never goes Live even when I enable it.
Is this a bug or is parenting cinemachines just not designed to work?
Parenting vcams has a special meaning in Cinemachine. In this case, as you have discovered, the child vcam will be hidden from the Brain and won’t ever go live. Keep them separate. Parenting is used for complex “manager-style” vcams like ClearShot, MixingCamera, and StateDrivenCamera.
Just in case anybody else is looking for this functionality in the future, I found having a second virtual cam match up nicely with the freelook cam pretty difficult, and even more difficult if you want camera panning to have momentum as with the freelook camera, or for the camera to have noise.