Search Unity

Forced default camera in State Driven Camera

Discussion in 'Cinemachine' started by Rami_FallDamage, Jul 25, 2018.

  1. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    Is there a way to not have a child to the State Driven Camera be forced to enabled? I wan't to be able to only have a camera active while the specified state is active. How it is now makes it impossible for me to have a setup where I have a VCam outside of the State Driven Camera that should be able to be active while the State Driven Camera is active.

    TL;DR I wan't to be able to have the first child disabled.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I'm not sure I understand your question.
    You want a vcam outside the SDC to be active when an animation state is active?
    Is this in addition to the vcam inside the SDC?
    If so, why do you need the SDC?
     
  3. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    The default camera for our game is a regular VCam, we have objects that have a SDC with higher prio, when their SDC is enabled the first child camera will automatically be enabled since the SDC forces it to be. This causes problems when we activate the SDC and then transition to a state, the first child camera will be active for a couple of frames when this happens.
     
  4. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    What I'm asking is that I would like to have our default camera, that is not in a SDC to be able to be active while an SDC with higher prio is active. To me it feels like a given that an SDC should be able to be active without any children active.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    hmmmm.... that would be breaking the paradigm. You're asking for the SDC to be the current active camera, yet do nothing and allow some other vcam (which one?) to do the work. There is only one current active camera.

    Can you arrange to activate your SDC only when the interesting state activates, and not before? That would solve your problem, I think.

    You can have the SDC active, but giving it a higher prio means "use this vcam now as the current active camera". Just don't give it a higher prio until you're ready for it to be the active vcam.
     
  6. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    I can't go into detail on how our game works but that is close to impossible. Because of how our game is structured, animations are very dynamic and we have little control of the exact frame they are triggered. It would be so much easier to just have an option to let children be disabled, or have child vcam priority matter with all other vcams in the scene.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Why not just make a script that monitors the state machine, and boosts the SDC priority when the interesting state is triggered?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Or, as a variation on that, you could make a default child vcam of the SDC, mapped to a "default" state, and attach a script that boosts the SDC's priority only while that default is not the live child of the SDC.
     
  9. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    That sounds like a good workaround, I will try it out.
     
  10. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    So I made a script that where I set the priority on the SDC to 0 in OnEnable, but it seems that there is a 1 frame lag from when you change priority and Cinemachine actually updating the active camera, if you use cut transitions then you will notice that frame. Is there any way to force it to update the active camera? I did some digging and it looks like
    UpdateVcamPoolStatus does this? But it's private and I want to try to avoid modifying the code, any ideas?
     
  11. Rami_FallDamage

    Rami_FallDamage

    Joined:
    Apr 4, 2017
    Posts:
    10
    Called it through Reflection, dirty solution but it works.
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Why would you set the SDC's priority to 0 in OnEnable? Why not just have it 0 to begin with?