Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

How do I lock rotation when using the group composer?

Discussion in 'Cinemachine' started by ShervinM, Sep 30, 2018.

  1. ShervinM


    Sep 16, 2017
    Hi there, firstlyI want to describe my set up:
    • Orthographic camera
    • Empty target group object that is rotated 45 degrees about X (I want my camera to always be at 45 degrees X), and rotation mode set to manual
    • CM Vcam with a Framing Transposer and Group Composer component.

    Now the vcam seems to frame my objects, but the issue is that it'll do all sorts of rotations as the objects move. I dont want any of these rotations, and wish to keep my camera always at a fixed height, and 45 degree rotation about the X axis. I have a Vcam extension to lock the height (so thats not a problem), but I cant seem to solve the rotation.

    I tried to make the following extension to lock the rotation (very similar to the height lock script), but this didnt work either:

    using UnityEngine;
    using Cinemachine;

    /// <summary>
    /// An add-on module for Cinemachine Virtual Camera that locks the camera's rotation
    /// </summary>
    [AddComponentMenu("")] // Hide in menu
    public class LockRotation : CinemachineExtension
    [Tooltip("Lock the camera's rotation to this value")]
    public Quaternion m_lockedRotation = Quaternion.Euler(new Vector3(45, 0, 0));

    protected override void PostPipelineStageCallback(
    CinemachineVirtualCameraBase vcam,
    CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    if (enabled && stage == CinemachineCore.Stage.Body)
    state.RawOrientation = m_lockedRotation;


    The best I've been able to achieve, is by changing the body to a Transposer (and not a Framing Transposer), and setting the binding mode to "Lock To Target On Assign". But this still does a very minor rotation when my objects move (eventually zeroing out).

    EDIT: Also, I should mention that I want to keep dead zone widths. Is this possible with the group composer? It seems (regardless of wonky rotations, and before any scaling of ortho size), the camera moves with every frame when my objects move even though I have strict dead zones set.

    Finally, another observation I've made is that in "Aim", with Group Composer selected, how come I dont see the "Adjustment Mode" option? Not sure if this in any way related, but figured I'd mention it (see attached picture of my Vcam component).

    Any help would be greatly appreciate it. Sorry for the wall of text :(

    Attached Files:

    Last edited: Sep 30, 2018
  2. Gregoryl


    Unity Technologies

    Dec 22, 2016
    You almost had it :)
    Body controls the vcam position, and Aim controls the vcam rotation. If you don't want the vcam to rotate, you have to put DoNothing in Aim.
    So: FramingTransposer in Body, and DoNothing in Aim. That will leave the vcam's rotation as you set it, while tracking and framing your group.
    abhineetprasad and ShervinM like this.
  3. ShervinM


    Sep 16, 2017
    A brilliant! Thank you Gregory! I just noticed that if I place a group as the FollowTarget it provides me with more options within Body (FramingTransposer) relevant to tracking/framing the group.

    Many thanks!!