Hi!
I searched quite long about this problem, but couldn´t find any solution to this.
I want to rotate the camera when the right mouse button is pressed depending from the mouse movement with limitation on the angle on the x axis.
When the angle reaches the max value, the rotation stops even when i´m still moving the mouse up, so this works fine. But when I reach the min value, the angle jumps up to the max value again. Shouldn´t it also stop to rotate when the min value is reached?
Here´s the code for this part:
private function rotateCamera():void{
if(Input.GetMouseButtonDown(1)){
this.mouseClickPosition = Input.mousePosition;
}
if(Input.GetMouseButton(1)){
var delta = this.mouseClickPosition - Input.mousePosition;
this.mouseClickPosition = Input.mousePosition;
this.transform.Rotate(Vector3.up * -this.speed * delta.x * Time.deltaTime);
this.transform.Rotate(Vector3.right * this.speed * delta.y * Time.deltaTime);
this.transform.rotation.eulerAngles.x = Mathf.Clamp(this.transform.rotation.eulerAngles.x, 0.0f, 40.0f);
}
}
I also tried some of the functions posted on other threads but it didn´t work either.
Thanks in advance.