Calculates a path from the current position of the vehicle to a specified destination. The destination will be the closest waypoint to the destination point.
usingGley.TrafficSystem;usingUnityEngine;publicclassTest:MonoBehaviour{ //a reference to vehicle pool and player assigned in inspectorpublicVehiclePool vehiclePool;publicTransform player;voidStart() {API.Initialize(player,20, vehiclePool);Events.onDestinationReached+= DestinationReached; }publicvoidSetDestination() { //set a random destination;Vector3 destination =newVector3(Random.Range(-500,500),0,Random.Range(-500,500)); //make the vehicle with index 5 drive to the destinationAPI.SetDestination(5, destination); }privatevoidDestinationReached(int vehicleIndex) {if(vehicleIndex==5) { //set another random destination for this vehicle if the previous one was reached.Vector3 destination =newVector3(Random.Range(-500,500),0,Random.Range(-500,500));API.SetDestination(vehicleIndex, destination); } }privatevoidOnDestroy() {Events.onDestinationReached-= DestinationReached; }}