private const float Y_ANGLE_MIN = 0.0f;
private const float Y_ANGLE_MAX = 50.0f;
public Quaternion rotacion = Quaternion.identity;
public Transform lookat;
public Transform camtransform;
private Camera cam;
public float distance = 40.0f;
public float currentX = 0.0f;
public float currentY = 0.0f;
public float sensivityx = 4.0f;
public float sensivityy = 4.0f;
// Use this for initialization
private void Start () {
camtransform = transform;
cam = Camera.main;
}
private void Update () {
currentX += Input.GetAxis ("Mouse X");
currentY -= Input.GetAxis ("Mouse Y");
currentY = Mathf.Clamp (currentY, Y_ANGLE_MIN, Y_ANGLE_MAX);
}
void LateUpdate () {
Vector3 dir = new Vector3 (0, 0, -distance);
Quaternion rotation = Quaternion.Euler (currentY, currentX, 0);
camtransform.position = lookat.position + rotation * dir;
camtransform.LookAt (lookat.position);
}