I have checked the WHOLE Script! I cannot seem to find any problems! Can anybody help me please? I’m getting: BCE0017: The best overload for the method ‘UnityEngine.Vector3.Distance(UnityEngine.Vector3, UnityEngine.Vector3)’ is not compatible with the argument list ‘(UnityEngine.Vector3, UnityEngine.Transform)’.
My Script:
#pragma strict
private var waypoints : GameObject[];
var maxSize : int = 12;
private var currentIndex : int;
private var currentWaypoint : Transform;
var ourCamera : Transform;
var done : boolean = false;
var thingToLookAt : Transform;
function Start () {
currentIndex = 0;
waypoints = new GameObject[maxSize];
for (var child : Transform in transform)
{
if (currentIndex < maxSize)
{
waypoints[currentIndex] = child.gameObject;
++currentIndex;
}
}
currentWaypoint = GetNextWaypoint();
}
function Update () {
if (done == false)
{
if (currentWaypoint != null)
{
if (Vector3.Distance(ourCamera.position, currentWaypoint) < .5)
{
currentWaypoint = GetNextWaypoint();
}
else
{
ourCamera.position = Vector3.Lerp(ourCamera.position, currentWaypoint.position, Time.deltaTime * 2);
ourCamera.transform.LookAt(thingToLookAt);
}
}
else
done = true;
}
}
function GetNextWaypoint()
{
if (currentIndex > 0)
{
var nextWaypoint : Transform = waypoints[currentIndex - 1].transform;
--currentIndex;
return nextWaypoint;
}
else
return null;
}