GetVehicleComponent

Description

Gets the Vehicle Component from the vehicle with the index passed as a parameter.

Declaration

public static VehicleComponent GetVehicleComponent(int vehicleIndex)

Parameters

NameDescription

vehicleIndex

The index of the vehicle to get the component from.

Returns

VehicleComponent - the component from the vehicle with the index passed as a parameter.

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 ExcludeVehicle()
    {
        //get the vehicle component from the vehicle with index 0 and debug its max speed
        VehicleComponent component = API.GetVehicleComponent(0);
        if (component != null)
        {
            Debug.Log(component.GetMaxSpeed());
        }
    }
}

Last updated