SetIntersectionRoadToGreen

Description

Force a road from a traffic light intersection to change to green.

Declaration

public static void SetIntersectionRoadToGreen(string intersectionName, int roadIndex, bool doNotChangeAgain = false)

Parameters

NameDescription

intersectionName

Name of the intersection to change.

roadIndex

The road index to change.

doNotChangeAgain

If true that road will stay green until this parameter is set back to false.

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 SetRoadToGreen()
    {
        //change the road 0 of Intersection_2 to green and keep it green.
        API.SetIntersectionRoadToGreen("Intersection_2", 0, true);
    }
}

Last updated