Search Unity

How might I rotate virtual camera (orb transposer) around a screen point.

Discussion in 'Cinemachine' started by Meatloaf4, Jun 14, 2019.

  1. Meatloaf4

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    183
    I'm going for the camera behavior very similar to pokemon go.

    Below is a snapshot of how my current camera setup looks. So far everything looks good but, I wasn't entirely sure how to map the rotation on to the Mouse X.

    Current CameraControllerCode

    Code (CSharp):
    1. void Start(){
    2.     CinemachineCore.GetInputAxis = GetInputAxisHandler;
    3. }
    4.  
    5. public float GetInputAxisHandler(string axisName)
    6. {
    7.     if(axisName == "Mouse X")
    8.     {
    9.         if (Input.GetMouseButton(0) || Input.touchCount > 0){
    10.             // not correct behavior as it just spins the camera as I move mouse from left to right
    11.             return (Input.touchCount > 0) ? Input.touches[0].deltaPosition.x : Input.GetAxis("Mouse X");
    12.         }
    13.         return 0;
    14.     }
    15. }

    upload_2019-6-14_14-9-11.png
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Your script is mapping mouse X to orbit angle, so camera is orbiting as you move mouse X.
    What do you want instead? Can you describe it?