Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

How To Set The Body/framing Tranposer/camera Distance Property From An Extension Or Else?

Discussion in 'Cinemachine' started by Jean-Fabre, Apr 15, 2019.

  1. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Everyone,

    I tried to make sense of Cinemachine very complex api :) and I am lost as to how to set the Camera Distance from within an extension...



    I tried to look at some extensions but none are accessing such data from within the virtual camera.

    Any hint would be welcome!

    Thanks :)

    Bye,

    Jean
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,747
    vcam.GetCinemachineComponent<CinemachineFramingTransposer>().m_CameraDistance = bla;
     
  3. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    yes! also, because the extension returns the CinemachineVirtualCameraBase, not the CinemachineVirtualCamera, you need to do this.

    ((CinemachineVirtualCamera)vcam).GetCinemachineComponent<CinemachineFramingTransposer>().m_CameraDistance = xxx;

    Thanks Gregoryl!

    Bye,

    Jean
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,747
    Yeah, it's not the best.
    I hope you're being safe and checking for nulls, in case the extension is added to another kind of vcam.