Search Unity

Camera parenting independent of transform hierarchy?

Discussion in 'Cinemachine' started by xpation, Jun 19, 2019.

  1. xpation

    xpation

    Joined:
    Mar 8, 2013
    Posts:
    9
    In our project, we've created a camera system that makes good use for the multi-tiered hierarchical meta-camera system that Cinemachine provides, and it's been very powerful. However, we've run into a limitation.

    Some of our meta-cameras have child cameras that are strewn all over the hierarchy across multiple scenes. This due to the complex nature of our project and scene organisation.

    While the meta-camera itself (inherited from CinemachineVirtualCameraBase) can keep track of all these children just fine, some of the functionality in Cinemachine (eg. the IsLive method of the CinemachineBrain) relies on an implementation of ParentCamera that only works if child cameras are direct children of their parent meta-cameras in the transform hierarchy.

    Our camera and scene setup simply doesn't allow for this. Would it be possible for the camera-parenting functionality of Cinemachine to become independent of the transform hierarchy, and to allow a parent camera to define itself as its children's parent in another way?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    We hear you, but that would be rather a significant change, so it's unlikely to happen in the near future. Maybe there's a workaround for you.

    First of all, it's great to hear that you're digging into CM and extending it. I'd love to see the results.

    Yes, CM assumes that a vcam can have a maximum of one vcam parent. What if you take the vcams that have multiple meta-parents, and unparent them. Make them top-level vcams (i.e. not parented to another vcam). Then IsLive will work properly for them. Could that approach work for you?
     
  3. xpation

    xpation

    Joined:
    Mar 8, 2013
    Posts:
    9
    The vcams don't have multiple parents, they only have one vcam parent, but they can't be children of that vcam under a single transform hierarchy within the Unity scene since we have our cameras structured under a number of different roots, under a number of different scenes.

    The nice thing with having them as child vcams and not top level ones is that there's a lot of hierarchical vcam goodness that is part of CM's architecture that we're leveraging. Having them as top level vcams means we'll need to write a hierarchical camera manager ourselves, something that already exists in CM.

    Currently considering doing some live moving of cameras into and out of the CM hierarchy as they get activated/deactivated, though it seems kind of hacky.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I'm having a bit of a hard time understanding what you're doing, but it sounds interesting.

    If you could put together a baby version of this with just a small handful of vcams and a few trivial assets and send it to me as a unitypackage, that would be awesome. Then I could understand it better and perhaps offer you some constructive suggestions.
     
  5. xpation

    xpation

    Joined:
    Mar 8, 2013
    Posts:
    9
    Ok awesome thanks! :) I'm doing the reparenting workaround now and that works fine, so I think we'll go with that for the time being, since like you said, Cinemachine won't be re-engineered to support cameras being outside of the transform hierarchy.