- Home /
BCE0017: Script Help
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;
}
Answer by Eric5h5 · Sep 08, 2012 at 08:22 PM
As the error says, you can't use a Vector3 and a Transform in Distance. You can only use a Vector3 and a Vector3. Presumably you mean transform.position, which is a Vector3.
The thing is that I'm trying to do this: http://www.youtube.com/watch?v=1xXR7CPRSaU I have done everything he did! Am I missing something?
To specify: currentWaypoint.position ins$$anonymous$$d of just currentWaypoint (Update function - 3rd if)
currentWaypoint is a variable of type Transform and contains more than just the position (namely orientation and scale).
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
FPS Ai help 1 Answer
Very simple inventory script... 0 Answers
Audio help. 1 Answer
My health decreases to fast. 1 Answer