here is my Mario Clone script that i am doing for my class: if someone can help me with this i would really appreciate it thanks in advance. i have redone this many times - thinking i am missing something from my teachers video - but i keep getting the same error,, any reasons why this would happen?
public class Camerafollow : MonoBehaviour {
public Transform target;
public Transform leftBounds;
public Transform rightBounds;
public float smoothDampTime = 0.15f;
private Vector3 smoothDampVelocity = Vector3.zero;
private float camWidth, camHeight, levelMinX, levelMaxX;
// Use this for initialization
void Start () {
camHeight = Camera.main.orthographicSize * 2;
camWidth = camHeight * Camera.main.aspect;
float leftBoundsWidth = leftBounds.GetComponentInChildren().bounds.size.x / 2;
float rightBoundsWidth = rightBounds.GetComponentInChildren().bounds.size.x / 2;
levelMinX = leftBounds.position.x + leftBoundsWidth + (camWidth/2);
levelMaxX = rightBounds.position.x - rightBoundsWidth - (camWidth/2);
}
// Update is called once per frame
void Update () {
if (target) {
float targetX = Mathf.Max(levelMinX, Mathf.Min(levelMaxX, target.position.x));
float x = Mathf.SmoothDamp(transform.position.x, targetX, ref smoothDampVelocity, smoothDampTime);
transform.position = new Vector3(x, transform.position.y, transform.position.z);
}
}
}
and here is the error messages i am getting
Assets/scripts/Camerafollow.cs(36,29): error CS1502: The best overloaded method match for `UnityEngine.Mathf.SmoothDamp(float, float, ref float, float)' has some invalid arguments
Assets/scripts/Camerafollow.cs(36,29): error CS1503: Argument `#3' cannot convert `UnityEngine.Vector3' expression to type `float'
↧