Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CinemachineStateDrivenCamera Change state programmatically

Discussion in 'Cinemachine' started by Censureret, Sep 22, 2020.

  1. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    I have some states in my ChineMachineStateDriven camera where some of the states can't be directly defined by the animator. So i really want to change camera programmatically in some cases. is there a way i can force change it through code?
     
  2. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    363
    Or even better is there a way to ensure that i can base the states on something else?
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    The StateDrivenCamera is just a switcher that chooses a vcam child based on specific input, in this case the current state of an Animator, because that is a common use-case.

    You can write a custom switcher that chooses a vcam child based on any arbitrary input conditions. You can use StateDrivenCamera as a starting template: copy it and modify the part that chooses a vcam.