Question by 
               fabiobatu72 · May 05, 2018 at 07:47 PM · 
                gamelook  
              
 
              i cant look up and down,any help?
P.S:i have already m made a game using the same code and it does work to move the camera up and down,the only difference is that in that game i used a cube and in this game i am using a cylinder as "Player"
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerLook : MonoBehaviour { public Transform playerBody; public float mouseSensitivity;
 float xAxisClamp = 0.0f;
 void Awake()
 {
     Cursor.lockState = CursorLockMode.Locked;
 }
 void Update()
 {
     RotateCamera();       
 }
 void RotateCamera()
 {
     float mouseX = Input.GetAxis("Mouse X");
     float mouseY = Input.GetAxis("Mouse Y");
     float rotAmountX = mouseX * mouseSensitivity;
     float rotAmountY = mouseY * mouseSensitivity;
     xAxisClamp -= rotAmountY;
     Vector3 targetRotCam = transform.rotation.eulerAngles;
     Vector3 targetRotBody = playerBody.rotation.eulerAngles;
     targetRotCam.x -= rotAmountY;
     targetRotCam.z = 0;
     targetRotBody.y += rotAmountX;
     if(xAxisClamp > 90)
     {
         xAxisClamp = 90;
         targetRotCam.x = 90;
     }
     else if(xAxisClamp < -90)
     {
         xAxisClamp = -90;
         targetRotCam.x = 270;
     }
     print(mouseY);
     transform.rotation = Quaternion.Euler(targetRotCam);
     playerBody.rotation = Quaternion.Euler(targetRotBody);
 }
 
               }
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
How do you get your game back if it says it is deleted 0 Answers
How to add dash to my character in Unity 3D? 0 Answers
How I can move a object with movements of my head? 0 Answers
Blendshapes is broken in Unity 2021 0 Answers
Collider disabling by itself... 2 Answers