Adds a traffic vehicle to the nearest waypoint from the provided position. The standard Traffic System conditions, such as avoiding adding a vehicle if it is within the player's view, will be bypassed. It is the developer's responsibility to ensure that it is safe to add the vehicle.
This method will wait until a vehicle of that type is available, and the closest waypoint is free to add a new vehicle. The process runs in the background until the new vehicle is successfully added.
usingGley.TrafficSystem;usingUnityEngine;publicclassTest:MonoBehaviour{ //a reference to vehicle pool and player assigned in inspectorpublicVehiclePool vehiclePool;publicTransform player;voidStart() {API.Initialize(player,20, vehiclePool); } //hand-picked positionsVector3 startPosition =newVector3(0,0,0);publicvoidAddVehicle() { //0 - is an example index of the vehicleAPI.AddVehicle(startPosition,VehicleTypes.Car, CompleteMethod); }privatevoidCompleteMethod(VehicleComponent vehicleScript,int waypointIndex) {Debug.Log($"{vehicleScript.name} was instantiated on waypoint {waypointIndex}"); }}