> For the complete documentation index, see [llms.txt](https://gley.gitbook.io/mobile-traffic-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gley.gitbook.io/mobile-traffic-system/complete-api/settrafficlightscrossingstate.md).

# SetTrafficLightsCrossingState

### Description

Manually set the traffic light crossing state. The crossing will change instantly to the new color.

### Declaration&#x20;

```csharp
public static void SetTrafficLightsCrossingState(string crossingName, TrafficLightsColor newColor, bool stopUpdate= false)
```

### Parameters

<table><thead><tr><th width="198">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>crossingName</strong></td><td>The name of the street crossing.</td></tr><tr><td><strong>newColor</strong></td><td>the new color to change into.</td></tr><tr><td><strong>stopUpdate</strong></td><td>Stop crossing from automatically changing colors from now on.</td></tr></tbody></table>

### Example

```csharp
using Gley.TrafficSystem;
using UnityEngine;

public class Test : MonoBehaviour
{
    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.Z))
        {
            // Change crossing to red and keep automatic lights changing. 
            API.SetTrafficLightsCrossingState("LightsCrossingName1", TrafficLightsColor.Red);
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            // Change crossing to yellow and keep automatic lights changing. 
            API.SetTrafficLightsCrossingState("LightsCrossingName1", TrafficLightsColor.YellowRed,false);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            // Change crossing to red and keep red until new color is manually set. 
            API.SetTrafficLightsCrossingState("LightsCrossingName1", TrafficLightsColor.Red, true);
        }
    }
}
```
