RemoveVehicle

Description

Remove a specific vehicle from the scene bypassing the remove conditions of the Traffic System.

The removed vehicle will be instantiated again when requested by the Traffic System.

Declaration

public static void RemoveVehicle(GameObject vehicle)

public static void RemoveVehicle(int vehicleIndex)

Parameters

NameDescription

vehicle

The root gameobject of the vehicle to be removed from the scene.

vehicleIndex

The index of the vehicle to be removed from the scene.

Example

using Gley.TrafficSystem;
using UnityEngine;

public class Test : MonoBehaviour
{
    //a reference to vehicle pool and player assigned in inspector
    public VehiclePool vehiclePool;
    public Transform player;

    void Start()
    {
        API.Initialize(player, 20, vehiclePool);
    }

    public void RemoveVehicle()
    {
        API.RemoveVehicle(GameObject.Find("Sedan(Clone)0"));
    }
}

Last updated