Search Unity

How to change orientation of CM camera in code?

Discussion in 'Cinemachine' started by Onigiri, May 22, 2018.

  1. Onigiri

    Onigiri

    Joined:
    Aug 10, 2014
    Posts:
    482
    I want to copy orientation values from one CM camera to another but can't figure out how to do this. I can get orientation by
    Code (CSharp):
    1. Quaternion rot = cameraExploration.State.RawOrientation;
    but can't apply this quaternion with
    Code (CSharp):
    1. cameraCombat.State.RawOrientation = rot;
     
    Imapler7 likes this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    It depends on the vcam.
    If the vcam procedurally animates its orientation, then it will always override whatever you try to set.
    If the vcam has Do Nothing in Aim, then it takes its rotation state every frame from its transform. So in that case, just set the vcam's transform's rotation.
     
    Imapler7 likes this.