Search Unity

Editing Cinemachine Properties at Runtime

Discussion in 'Scripting' started by mvinc006, Mar 27, 2019.

  1. mvinc006

    mvinc006

    Joined:
    Jan 1, 2018
    Posts:
    91
    I'm stumped on how to access the 'Aim' property on the Cinemachine Virtual Camera.

    What I'm trying to achieve is that when the player Presses TAB, it will change the view to a POV where they can freely look around.

    I've hunted around, dug up some old threads that led to referencing the composer, though I don't see any direct correlation to the 'Aim' field itself. I dug deeper again, and seen through the base coding documentation that 'Aim' somehow correlates to 'Stage' in the code, well I couldn't find a way to reference the field from that either.

    Can anyone provide some advice/documentation (without saying look at the examples scene, I am using the Package Manager version which doesn't include this).
     
  2. CodeElemental

    CodeElemental

    Joined:
    Feb 6, 2014
    Posts:
    15
    Probably you already figured it out.
    Just for reference :

    Code (CSharp):
    1. public CinemachineVirtualCamera virtualCamera;
    2. CinemachineComponentBase componentBase = virtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Aim);
    3.  
    4. if (componentBase is CinemachineComposer) { /* Do smth */ }