Triggered every time a waypoint that has the Trigger Event option enabled is reached by a vehicle.


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);
        Events.onWaypointReached += WaypointReached;

    /// <summary>
    /// Triggered every time a waypoint with Trigger Event check mark on is reached
    /// </summary>
    /// <param name="vehicleIndex">the vehicle index that reached the waypoint</param>
    /// <param name="waypointIndex">the index of the waypoint</param>
    /// <param name="data">the data from the settings window</param>
    private void WaypointReached(int vehicleIndex, int waypointIndex, string data)
        Debug.Log(vehicleIndex + " " + waypointIndex + " " + data);

    private void OnDestroy()
        Events.onWaypointReached -= WaypointReached;

Last updated