, , , 。
:
function OnDrawGizmos () {
// make a new array of waypoints, then set it to all of the transforms in the current object
var waypoints = gameObject.GetComponentsInChildren( Transform );
// now loop through all of them and draw gizmos for each of them
for ( var waypoint : Transform in waypoints ) {
Gizmos.DrawSphere( waypoint.position, 1.0 );
}
}
に : if (waypoint[0] == null)
{
for (int i = 0; i < 53; i++)
{
waypoint[i] = GameObject.Find("point" + i);
}
}
if (waypoint[currentwaypoint] != null)
{
Vector3 relativeposition = transform.InverseTransformPoint(waypoint[currentwaypoint].transform.position.x, transform.position.y, waypoint[currentwaypoint].transform.position.z);
frontwheel.steerAngle = 50 * relativeposition.x / relativeposition.magnitude;
backwheel.motorTorque = 4;
if (relativeposition.magnitude < 2) currentwaypoint++;
if (currentwaypoint >= waypoint.Length) currentwaypoint = 0;
}