Search Unity

Setting FollowTarget for use with CinemachineFramingTransposer does not use Camera Distance

Discussion in 'Cinemachine' started by Ejlersen, Jan 31, 2020.

  1. Ejlersen

    Ejlersen

    Joined:
    Apr 30, 2009
    Posts:
    11
    I'm using a virtual camera with Framing Transposer to follow my character. I have the following settings:

    upload_2020-1-31_11-8-46.png

    The main camera is orthographic with a size of 10.

    I set my Follow target on runtime, since my character is loaded later by doing this:

    Code (CSharp):
    1. CinemachineVirtualCamera camera = GetComponent<CinemachineVirtualCamera>();
    2. camera.Follow = target;
    3. camera.enabled =  true;
    This does follow my character, but the Camera Distance is not used. It uses something else.

    The wrong distance used:
    upload_2020-1-31_11-13-26.png

    The correct distance used:
    upload_2020-1-31_11-12-13.png

    I can get the correct distance, if I remove the component and add it again. But then the transitions resets its start position to (0,0,0).
     

    Attached Files:

    Last edited: Jan 31, 2020
  2. Ejlersen

    Ejlersen

    Joined:
    Apr 30, 2009
    Posts:
    11
    Adding the extension "CinemachineCameraOffset" solves the problem, but the camera distance variable seems a lot cleaner. It also works, if I add the component again, so I don't know...
     
    Last edited: Jan 31, 2020
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    That's very strange. Can you repro this effect in a small project and send it to me?