- Home /
 
               Question by 
               shadowsensui · May 15, 2016 at 01:21 PM · 
                rotationquaternionclamped rotationfirst person shooterself  
              
 
              Self made FPS Controller not looking up or down
Hello fellow developers,
I'm trying to make my own FPS controller, the problem I'm having now is that it will not look up or down, I tried commenting up the clamping, or adding another transform.Rotation for that but It'll go all 360 degrees. Help would be greatly appreciated.
 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour {
 
     public float Speed;
     public float MouseSensitivity;
     float RotationY = 0;
 
     CharacterController CharController;
 
     // Use this for initialization
     void Start ()
     {
         CharController = GetComponent<CharacterController>();
     }
     
     // Update is called once per frame
     void Update ()
     {
         //ROTATION
         float RotationX = Input.GetAxis("Mouse X") * MouseSensitivity;
         transform.Rotate(0, RotationX, 0); // looking right and left
 
         Debug.Log(RotationY);
         RotationY = Input.GetAxis("Mouse Y") * MouseSensitivity;
         RotationY = Mathf.Clamp(RotationY, -60f, 60f);
         Camera.main.transform.localRotation = Quaternion.Euler(RotationY, 0, 0); // for looking up and down
 
         //MOVEMENT
         float VerMovement = Input.GetAxis("Vertical");
         float HorMovement = Input.GetAxis("Horizontal");
 
         Vector3 Movement = new Vector3(HorMovement, 0.0f, VerMovement);
 
         Movement = transform.rotation * Movement; //resets the coridenates when rotating
 
         CharController.SimpleMove(Movement * Speed);
     }
 }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Rotate from HorizantalSlider in local not global help. 2 Answers
How to Clamp a Quaternion Camera Rotation? 0 Answers
Clamped Rotate 3D Object on Y and Z axis only with OnMouseDrag() 2 Answers
Quaternion Rotation On Specific Axis Issue 0 Answers
Calculate rotation angle for two side of cube ( like dice ) from Quaternion.identity 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                