i am currently digging into javascript and writing some small scripts, but i’m currently having some problems with a camera script. I read out the MouseX and MouseY and use it to change the cameras local rotation
if (Input.GetMouseButton(2))
{
var verticalrotation : float = horizontalSpeed * Input.GetAxis ("Mouse X");
var horizontalrotation : float = verticalSpeed * Input.GetAxis ("Mouse Y");
transform.Rotate (Vector3.right*horizontalrotation);
transform.Rotate (Vector3.up*verticalrotation);
}
and
if (Input.GetMouseButton(2))
{
var verticalrotation : float = horizontalSpeed * Input.GetAxis ("Mouse X");
var horizontalrotation : float = verticalSpeed * Input.GetAxis ("Mouse Y");
transform.Rotate (horizontalrotation,verticalrotation,0);
}
of course do the same, but when i move my mouse in circles over the table it rotates the camera on its local z axis and creates a tumbling motion around the horizon, but i always want the camera to be upright