I didn’t want to use the inbuilt script or copy a script from another Answers thread so please don’t post a different script, I’d like to figure out the issue so I’m able to learn from it. I’ve created this script that I placed on my Player (Parent) and Camera (Child), I enable the Y on the Camera and the X on the Player but it seems to be cancelling the Player out.
using UnityEngine;
using System.Collections;
public class PlayerAiming : MonoBehaviour {
[Header("Toggle")]
public bool isX;
public bool isY;
[Header("Sensitivity")]
public float Sensitivity;
private float yRotation;
private float xRotation;
private float curYRotation;
private float curXRotation;
private float yRotationV;
private float xRotationV;
private float Damp=0.1f;
void Update () {
yRotation += Input.GetAxis ("Mouse X") * Sensitivity;
xRotation -= Input.GetAxis("Mouse Y") * Sensitivity;
xRotation = Mathf.Clamp (xRotation, -90, 90);
curXRotation = Mathf.SmoothDamp (curXRotation, xRotation, ref xRotationV, Damp);
curYRotation = Mathf.SmoothDamp (curYRotation, yRotation, ref yRotationV, Damp);
if (isX) {
transform.rotation = Quaternion.Euler (0, yRotation, 0);
}
if (isY) {
transform.rotation = Quaternion.Euler (xRotation, 0, 0);
}
}
}