Search Unity

How to get the virtual camera to keep object in view?

Discussion in 'Cinemachine' started by TheCelt, Aug 31, 2019.

  1. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Hi

    I have a virtual camera following a large object. How can i make it auto adjust to keep the entire object in view ? I am not sure what i need to set it up.
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Consider attaching a CinemachineTargetGroup to your Virtual Camera. This allows you to frame multiple objects at once. With this you can place some small objects (perhaps non-rendering) at the edges of your large object and always keep the entire object in view.
     
    lodyny and Gregoryl like this.
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Yes, that's a very good idea.

    To clarify: create a new GameObject and add the CinemachineTragetGroup behaviour to it. Add your target object and the extra (perhaps non-rendering) objects to the target group. Then, use that target group as a look-at target for your vcam, and set the vcams' Aim to Group Composer. That will expose some settings that let you control how the group is kept in frame. Or, if it's a 2D vcam with a Framing Transposer, it will auto-detect the group and you can leave Aim on the Do Nothing setting.
     
    lodyny likes this.