# Player In Trigger

## Description

Controls how the traffic vehicle reacts when a player car is in trigger.

## Declaration

```csharp
public delegate void PlayerInTrigger(int vehicleIndex, Collider player);
```

## Parameters

<table><thead><tr><th width="203">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>vehicleIndex</strong></td><td>The index of the vehicle that saw the player.</td></tr><tr><td><strong>player</strong></td><td>The collider of the player.</td></tr></tbody></table>

## Set Method

```csharp
public static void SetPlayerInTrigger(PlayerInTrigger playerInTriggerDelegate)
```

## Example

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

public class Test : MonoBehaviour
{
    private void Start()
    {
        Delegates.SetPlayerInTrigger(MyPlayerInTriggerBehaviour);
    }

    public static void MyPlayerInTriggerBehaviour(int vehicleIndex, Collider player)
    {
        //if the player is seen, the speed is adapted to the speed of the player.
        API.AddDrivingAction(vehicleIndex, DriveActions.Follow, false);
    }
}
```

{% hint style="info" %}
Default delegate implementation can be found inside **DefaultDelegates.cs**
{% endhint %}
