- Home /
Question by
case_one · Dec 21, 2012 at 12:17 AM ·
camerajavascriptmouselook
MouseLook.cs:case of JavaScript
Unity StandardAssets/CharacterControllers/Sources/Scripts/MouseLook.cs
MouseLook.cs→a case of javascript
I thank you for your kindness.
Comment
Best Answer
Answer by clunk47 · Dec 21, 2012 at 12:17 AM
enum RotationAxes {MouseX, MouseY, MouseXandY};
var axes : RotationAxes;
private var MouseX = RotationAxes.MouseX;
private var MouseY = RotationAxes.MouseY;
private var MouseXandY = RotationAxes.MouseXandY;
var sensitivityX : float = 15F;
var sensitivityY : float = 15F;
var minimumX : float = -360F;
var maximumX : float = 360F;
var minimumY : float= -60F;
var maximumY : float = 60F;
var rotationY : float = 0F;
function Update ()
{
if (axes == MouseXandY)
{
var rotationX : float = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = Vector3(-rotationY, rotationX, 0);
}
else if (axes == MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
function Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
Always very happy to help. If this answer resolved your issue, I would be greatly appreciative if you would be so kind to Vote up(thumbs up icon) or Accept(checkmark) the answer. Have a wonderful evening :)
Your answer
Follow this Question
Related Questions
fps MouseLook with animation applied to camera. 1 Answer
How to change main camera and access to the other scripts?? 0 Answers
Camera movement in a 2D? (like angry birds) 1 Answer
How to change overlay with timer? 0 Answers
Rotating Main Camera 1 Answer