I have a simple script setup that is attached to my Camera object that simply rotates around the player when there is input from the mouse. But it seems the axis input is incorrect because when I move the mouse up, it actually rotates on the X axis, and then moving left or right moves it up and down the player on the Y axis. I am on OS X/Mac with MagicMouse.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonCamera : MonoBehaviour {
private const float Y_ANGLE_MIN = -50.0f;
private const float Y_ANGLE_MAX = 50.0f;
public Transform lookAt;
public Transform camTransform;
private Camera cam;
private float distance = 2.0f;
private float currentX = 0.00f;
private float currentY = 0.00f;
private float sensitivityX = 8.0f;
private float sensitivityY = 8.0f;
// Use this for initialization
private void Start () {
camTransform = transform;
cam = Camera.main;
}
// Update is called once per frame
private void Update () {
currentX += Input.GetAxis ("Mouse X");
currentY -= Input.GetAxis ("Mouse Y");
currentY = Mathf.Clamp (currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
}
private void LateUpdate() {
Vector3 dir = new Vector3 (0, 0, -distance);
Quaternion rotation = Quaternion.Euler (currentX, currentY, 0);
cam.transform.position = lookAt.position + rotation * dir;
camTransform.LookAt (lookAt.position);
}
}