GetExcludedVehicleList

Description

Returns a list of all excluded vehicles. Useful to manage the instantiation of specific vehicles in specific locations.

Declaration

 public static List<VehicleComponent> GetExcludedVehicleList()

Returns

List<VehicleComponent> - the components associated with each vehicle marked as excluded from the Traffic System.

Example

GameObject instantiateLaterVehicle;

//after the traffic system is initialized
void OnTrafficInitializedCallback()
{
    //get the complete list of excluded vehicle
    List<VehicleComponent> excludedVehicle = API.GetExcludedVehicleList();

    foreach (VehicleComponent vehicleComponent in excludedVehicle)
    {
        if (vehicleComponent.vehicleType == VehicleTypes.SomeType)
        {
            //do something
            //save the vehicle
            //do whatever you want

            //I will save the GamaObject for later use
            instantiateLaterVehicle = vehicleComponent.gameObject;
        }
    }
}

//at the right time instantiate the vehicle using one of those 2 options
void InstantiateExcludedVehicle()
{
    //manually add vehicle to a specified position
    API.AddExcludedVehicle(API.GetExcludedVehicleIndex(instantiateLaterVehicle), position);

    //add the vehicle to the system and it will be automatically instantiated like any other vehicle
    API.AddExcludedVehicleToSystem(API.GetExcludedVehicleIndex(instantiateLaterVehicle));
}

Last updated