unity 3 d車両は自分で設定した標識点に従って移動する


          ,        ,          ,        。
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;
                }