I looked everywhere but no codes seem compatible i tried adding another Plane() with little success. So how do you make the LookAtMouse script look up and down with a field of view limit?
This is what I got in terms of code what can I do to limit the angles to just making the camera looking up and down:
*EDIT: I got it to lock in the axisee but its too buggy the other axisees still move
So you only want the camera to look up and down and clamp the angles up and down. To solve this, you need to look at the MouseOrbit script. It contains a function called ClampAngle.
In the code I provide you, I modified your code to clamp the local X angle so that it limits the amount that the camera will look up and down. I also changed the way you pull the ray to only pull the Y movement (which corresponds to the camera’s X axis)
I can’t test it right now, and I am not sure it is what you want.
var speed = 10.0;
var xMinLimit = -60;
var xMaxLimit = 60;
function LateUpdate() {
var ray = Camera.main.ScreenPointToRay (Vector3(Screen.width/2, Input.mousePosition.y, 0));
var hitdist = 10.0;
var targetPoint = ray.GetPoint(hitdist);
var currentRotation=transform.rotation;
transform.LookAt(targetPoint);
transform.rotation = Quaternion.Slerp(currentRotation, transform.rotation, speed * Time.deltaTime);
transform.localEulerAngles.x=ClampAngle(transform.localEulerAngles.x, xMinLimit, xMaxLimit);
}
static function ClampAngle (angle : float, min : float, max : float) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}
Thank you for the script and the detailed information you don’t get that much on the forums(or any forums for that matter). The script works for the most part. It clamps up down(but likes to jump from top to bottom when you look to much words the sky) Im sure i’ll get it working the way i want it soon thanks again!