Apply the Camera Rotation Y to Player Gameobject Y
Hi Guys, I made a simple mouselook script. The script itself is working just fine, the camera rotates as i move my mouse. I added the script to the camera and now i want the camera rotation Y be the same with my gameobject player rotation y. my camera is a child of my player gameobject.
//Camera Movement
private float RotationY;
private float RotationX;
private float MinimumY = -90;
private float MaximumY = 90;
public float LookSensitivity;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * LookSensitivity;
RotationY += Input.GetAxis("Mouse Y") * LookSensitivity;
RotationY = Mathf.Clamp(RotationY, MinimumY, MaximumY);
transform.localEulerAngles = new Vector3(-RotationY, RotationX, 0);
}
Comment
Your answer
Follow this Question
Related Questions
Rotating the player with mousePosition problem. 0 Answers
Smooth Camera Mouse Clamp, Damp 0 Answers
Screen to World Position: Can't seem to get it right 0 Answers
Freeze camera rotation C# 1 Answer