> 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/initialize.md).

# Initialize

### Description

Initializes the entire Traffic System by adding all the necessary components before starting the Traffic System.

This method should be called only once at the beginning of the scene.

### Declaration&#x20;

Supports multiple declarations based on the needs.

```csharp
public static void Initialize(Transform activeCamera, int nrOfVehicles, VehiclePool vehiclePool)

public static void Initialize(Transform activeCamera, int nrOfVehicles, VehiclePool vehiclePool, TrafficOptions trafficOptions)

public static void Initialize(Transform[] activeCameras, int nrOfVehicles, VehiclePool carPool, TrafficOptions trafficOptions)
```

### Parameters

<table><thead><tr><th width="188">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>activeCamera</strong></td><td>Camera that follows the player or the player itself. Used to determine the line of sight for vehicle instantiations.</td></tr><tr><td><strong>nrOfVehicles</strong></td><td>The maximum number of traffic vehicles that can be active simultaneously. This value cannot be increased later during runtime.</td></tr><tr><td><strong>vehiclePool</strong></td><td>Available vehicles asset. More details about the Vehicle Pool, including its configuration can be found in Setup Guide: <a data-mention href="/mobile-traffic-system/setup-guide/vehicle-pool.md">Vehicle Pool</a></td></tr><tr><td><strong>trafficOptions</strong></td><td>A <a href="/mobile-traffic-system/complete-api/trafficoptions.md">TrafficOptions </a>object used to store the initialization properties.</td></tr><tr><td><strong>activeCameras</strong></td><td>Cameras that follow the players. Utilized in multiplayer scenarios.</td></tr></tbody></table>

### Example

Initializing the Traffic System inside a scene.

```csharp
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()
    {
        //set initialization parameters. if not assigned the default value will be used
        TrafficOptions options = new TrafficOptions()
        {
            activeSquaresLevel = 2,
            distanceToRemove = 150,
            minDistanceToAdd = 100
        };

        API.Initialize(player, 20, vehiclePool, options);
    }
}
```
