Ok here is the default mouselook we get, and I have a bit of questions to ask about it.
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F;
public float sensitivityY = 15F;
public float minimumX = -360F;
public float maximumX = 360F;
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.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);
}
}
void Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
}
1.
using UnityEngine;
using System.Collections;
What is that ?
2.
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
What is the addcomponentmenu thing?
What exactly is a MonoBehavior?
What is a enum and how does the stuff in the { } work ?
What is he doing with public rotationAxes axes=rotationaxes.mousexandy ?
3.
public float sensitivityX = 15F;
what is with the F behind 15?
4.
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
What is with the void in void Update() ?
How does the if statement here work, it kinda throws me off (maybe because i dont understand the questions i posted above)?
5.
void Start ()
{
// Make the rigid body not change rotation
if (rigidbody)
rigidbody.freezeRotation = true;
}
again what is the void, and what rigid body is it freezing and why ?
6.
Could I get just a general run down of how the script works mainly in the If statement area since i already asked about most of the rest?
Thank you so much for taking your time to help me understand this so I can improve my abilities.