> For the complete documentation index, see [llms.txt](https://gley.gitbook.io/mobile-pedestrian-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-pedestrian-system/events/onpedestrianadded.md).

# OnPedestrianAdded

### Description

Triggered every time a pedestrian is activated inside the scene.

### Delegate

```csharp
public delegate void PedestrianAdded(int pedestrianIndex, Vector3 position);
```

### Parameters

| Name                | Description                  |
| ------------------- | ---------------------------- |
| **pedestrianIndex** | The index of the pedestrian. |
| **position**        | The instantiation position.  |

### Example

```csharp
using Gley.PedestrianSystem;
using UnityEngine;


public class Test : MonoBehaviour
{
    // A reference to the pedestrian pool and player assigned in the inspector.
    public PedestrianPool PedestrianPool;
    public Transform Player;

    void Start()
    {
        Events.OnPedestrianAdded += PedestrianAdded;
        API.Initialize(Player, 1, PedestrianPool);
    }

    private void PedestrianAdded(int pedestrianIndex, Vector3 position)
    {
        Debug.Log($"Pedestrian with index {pedestrianIndex} was added at position {position}");
    }

    private void OnDestroy()
    {
        Events.OnPedestrianAdded -= PedestrianAdded;
    }
}
```
