// Use this for initialization void Start() { move = GetComponent <Move>(); seek = GetComponent <SteeringSeek>(); // TODO 1: Calculate the closest point from the tank to the curve //float min_dist = float.MaxValue; //int closestPoint = 0; //for (int i = 0; i < curve.Curve.PointsCount; ++i) //{ // float newDist = Vector3.Distance(transform.position, curve.Curve[i].PositionWorld); // if (newDist < min_dist) // { // min_dist = newDist; // closestPoint = i; // } //} //trgPoint = closestPoint; totalPathDist = path.GetDistance();//If you don't put anything you get the total distance of the path float distance = 0f; transform.position = path.CalcPositionByClosestPoint(transform.position, out distance); trgPointIdx = path.CalcSectionIndexByDistance(distance); currRation = trgPointRation = distance / totalPathDist; }