Hello everyone. I have an error and i don’t know how can i fix that.
Here is the code!
using UnityEngine;
using System.Collections;
public class CameraTest : MonoBehaviour {
public Transform target;
public float distance = 10.0f;
public float xSpeed = 250.0f;
public float ySpeed = 120.0f;
public float yMinLimit = -20f;
public float yMaxLimit = 80f;
private float x = 0.0f;
private float y = 0.0f;
// Use this for initialization
void Start () {
x = transform.eulerAngles.y;
y = transform.eulerAngles.x;
if (rigidbody)
rigidbody.freezeRotation = true;
}
// Update is called once per frame
public void LateUpdate () {
if (target) {
if(Input.GetMouseButton(1)){
x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
}
y = ClampAngle(y, yMinLimit, yMaxLimit);
transform.rotation = Quaternion.Euler(y, x, 0);
transform.position = transform.rotation * Vector3(0.0, 0.0, -distance) + target.position;
}
}
static float ClampAngle (float angle, float min, float max) {
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
return Mathf.Clamp (angle, min, max);
}
}
and the error is that
error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected