GetVehicleSpeed

Description

Get the current speed in km/h of the vehicle.

Declaration

 public static float GetVehicleSpeed(int vehicleIndex)

Parameters

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 GetVehicleSpeed()
    {
        Debug.Log($"Speed: {API.GetVehicleSpeed(0)} km/h");
    }
}

Last updated