- Home /
[JS] Custom camera rotation resets on Var change?
Hello everyone! Right now i am in the proces of making a custom third person character, and i am currently working on getting the camera to work.
However, when i change the rotatesensitivity in the inspector window while the game is running, it does change the sensitivity properly the way i want it, but whenever the var is changed in game, the camera resets its rotation as soon as the camera moves.
I know this is probably something very simple i'm overlooking, caused by the wrong usage of the rotatesensitivity var, but i just can't see it.
 // nog toevoegen: min zoom en max zoom
 
 
 #pragma strict
 //var dump
 public var camhold :boolean = false;
     var horizontalSpeed : float = 2.0;
     var verticalSpeed : float = 2.0;
     var Vrotation : float = 0;
     var Hrotation : float = 0;
     var rotatesensitivity : float = 2.0;
     public var MouseZoomSpeed : float = 1;
 function Start () {
 
 }
 //camera movement definitions
 function Update () {
 
     var h : float = horizontalSpeed * Input.GetAxis ("Mouse X");
     var v : float = verticalSpeed * Input.GetAxis ("Mouse Y");
     
 //zooming in and out
 if (Input.GetAxis("Mouse ScrollWheel") < 0)
 {
     transform.localScale += new Vector3(0.1f * MouseZoomSpeed, 0.1f * MouseZoomSpeed, 0.1f * MouseZoomSpeed);
 }
     
     
 if (Input.GetAxis("Mouse ScrollWheel") > 0)
 {
     transform.localScale += new Vector3(-0.1f * MouseZoomSpeed, -0.1f * MouseZoomSpeed, -0.1f * MouseZoomSpeed);
 }
 
 //end of the zooming part
 
 if(Input.GetMouseButton(1)){
     camhold = true;
 //    print("test");
 }
 
 //the above checks for button input
 
 else {
 camhold = false;
 
 }
 //this part is for camera rotation V V V
     if (Input.GetAxis("Mouse Y") && camhold){
     transform.Rotate (v, h, 0);
     Vrotation += Input.GetAxis("Mouse Y");
     Hrotation += Input.GetAxis("Mouse X");
     transform.eulerAngles = Vector3(Vrotation * rotatesensitivity, Hrotation * rotatesensitivity, 0);
         
     }
 }
If you know what i'm doing wrong, your help would be greatly appreciated.
-Alex Beelen
Your answer
 
 
             Follow this Question
Related Questions
I need help with camera movement and rotation. 1 Answer
How Can I Stop Rotation From This Script? 0 Answers
Look at wont update? 2 Answers
"Perfect" Free Rotation Method? (like Blender) 2 Answers
Floats not being applied? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                