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

Some issues with an orbiting free look camera setup

Discussion in 'Cinemachine' started by jlink, Dec 27, 2018.

  1. jlink

    jlink

    Joined:
    Jan 8, 2017
    Posts:
    11
    I'm having some issues with an orbiting free look camera setup I'm using in my project. The goal is to have a camera orbit an object based on mouse movement when the left mouse button is pressed. My Cinemachine version is 2.2.7 and Unity is 2018.2.9f1. I'm having two issues currently:

    - In a build, orbit speed is much slower
    - In a build, orbiting can get "stuck" and never fully stop (though it gets close)

    I don't have the above issues in the editor. Here is my virtual camera setup:

    upload_2018-12-27_15-12-53.png

    upload_2018-12-27_15-13-17.png

    upload_2018-12-27_15-13-39.png

    upload_2018-12-27_15-13-57.png

    upload_2018-12-27_15-14-16.png

    To enable/disable orbiting I do the following:

    Code (CSharp):
    1. cinemachineFreelook.m_XAxis.m_InputAxisName = "Horizontal";
    2. cinemachineFreelook.m_YAxis.m_InputAxisName = "Vertical";
    and

    Code (CSharp):
    1. cinemachineFreelook.m_XAxis.m_InputAxisName = "";
    2. cinemachineFreelook.m_YAxis.m_InputAxisName = "";
    3.  
    4. cinemachineFreelook.m_XAxis.m_InputAxisValue = 0;
    5. cinemachineFreelook.m_YAxis.m_InputAxisValue = 0;
    Of course horizontal and vertical input is set to mouse movement in the input manager.

    Any idea how I can fix this?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Unable to repro your problem using Unity 2018.2.19f1 and CM 2.2.7. If behaves identically in build and editor, and never gets stuck. I've attached this script to the FreeLook to implement the button handling:

    Code (CSharp):
    1. using UnityEngine;
    2. using Cinemachine;
    3.  
    4. public class OrbitIfButton : MonoBehaviour
    5. {
    6.     CinemachineFreeLook freeLook;
    7.  
    8.     void Start()
    9.     {
    10.         freeLook = GetComponent<CinemachineFreeLook>();
    11.     }
    12.  
    13.     void Update()
    14.     {
    15.         if (Input.GetMouseButton(0))
    16.         {
    17.             freeLook.m_XAxis.m_InputAxisName = "Horizontal";
    18.             freeLook.m_YAxis.m_InputAxisName = "Vertical";
    19.         }
    20.         else
    21.         {
    22.             freeLook.m_XAxis.m_InputAxisName = "";
    23.             freeLook.m_YAxis.m_InputAxisName = "";
    24.  
    25.             freeLook.m_XAxis.m_InputAxisValue = 0;
    26.             freeLook.m_YAxis.m_InputAxisValue = 0;
    27.         }
    28.     }
    29. }
    30.  
    Are there any more details you can give about your project? Maybe you could put together a lightweight sample project that demonstrates this?