Hello people im trying to create a third person camera that follows the character and rotates around the character if you rotate your mouse but for some reason it only rotates the Y axis but not the X axis (so i can rotate above and under the player) am i doing something wrong in the code or is this a unity project settings issue??
using UnityEngine;
using System.Collections;
public class ThirdPersonCamera : MonoBehaviour {
public bool lockCursor;
public float mouseSensitivity = 7;
public Transform target;
public float dstFromTarget = 7;
public Vector2 pitchMinMax = new Vector2 (-40, 85);
public float rotationSmoothTime = .12f;
Vector3 rotationSmoothVelocity;
Vector3 currentRotation;
float yaw;
float pitch;
void Start() {
if (lockCursor) {
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
void LateUpdate () {
yaw += Input.GetAxis ("Mouse X") * mouseSensitivity;
pitch -= Input.GetAxis ("Mouse Y") * mouseSensitivity;
pitch = Mathf.Clamp (pitch, pitchMinMax.x, pitchMinMax.y);
currentRotation = Vector3.SmoothDamp (currentRotation, new Vector3 (pitch, yaw), ref rotationSmoothVelocity, rotationSmoothTime);
transform.eulerAngles = currentRotation;
transform.position = target.position - transform.forward * dstFromTarget;
}
}