Game Development Reference
In-Depth Information
50.
float currentRotation = camera.localRotation.eulerAngles.x;
51.
52.
//Convert vertical camera rotation from range [0, 360] 53.
//to range
[-180, 180]
54.
if(currentRotation > 180){
55.
currentRotation = currentRotation - 360;
56.
}
57.
58.
//Calculate rotation amout for current frame
59.
floatang=
60.
-mouseDelta.y * verticalMouseSpeed * Time.deltaTime; 61.
62.
//Step 2: rotate camera around it's local X
63.
//axis based on vertical mouse displacement
64.
//First check allowed limits
65.
if((ang < 0 && ang + currentRotation > -maxVerticalAngle) ||
66.
(ang > 0 && ang + currentRotation < maxVer-
ticalAngle)){
67.
camera.RotateAround(camera.right, ang);
68.
}
Search WWH ::




Custom Search