> 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/delegates/dynamic-obstacle-in-trigger.md).

# Dynamic Obstacle In Trigger

## Description

Controls how the traffic vehicle reacts when a dynamic obstacle is in the trigger.

## Declaration

```csharp
 public delegate void DynamicObstacleInTrigger(int vehicleIndex, Collider obstacle);
```

## 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 obstacle.</td></tr><tr><td><strong>obstacle</strong></td><td>The collider of the obstacle.</td></tr></tbody></table>

## Set Method

```csharp
public static void SetDynamicObstacleInTrigger(DynamicObstacleInTrigger dynamicObstacleInTriggerDelegate)
```

## Example

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

public class Test : MonoBehaviour
{
    private void Start()
    {
        Delegates.SetDynamicObstacleInTrigger(MyObstacleBehaviour);
    }

    public static void MyObstacleBehaviour(int vehicleIndex, Collider player)
    {
        //stop and wait
        API.AddDrivingAction(vehicleIndex, DriveActions.StopInDistance, false);
    }
}
```

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