- Home /
simple camera script
Hi, I'm working on a camera script, that should work like a simple FPS camera. In short: I'd like the camera to rotate according the mouse position in certain limits (e.g. 5 degrees in every direction). Here's my script so far:
 var speed : float;
 function Update(){    
     var mousePosition : Vector3 = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 20));
     transform.LookAt(mousePosition);
     if(Input.mousePosition.y > Screen.height/2 && transform.position.y < 4.5) {
         transform.position.y += Time.deltaTime * speed;
     }
     if(Input.mousePosition.y < Screen.height/2 && transform.position.y > 2.5) {
         transform.position.y -= Time.deltaTime * speed;
     }
 }
At the moment the camera is way too fast and rotates 360 degrees. I hope there's somebody, who can give me a hint.
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                