> 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/complete-api/setpedestrianbehaviours.md).

# SetPedestrianBehaviours

### Description

Change the complete beheviour list for a pedestrian. The old behaviours list for that pedestrian will be overridden. &#x20;

Read more about how to setup a new pedestrian behaviour here: [Pedestrian Behaviours](/mobile-pedestrian-system/setup-guide/pedestrian-behaviours.md)

### Declaration

```csharp
 public static void SetPedestrianBehaviours(int pedestrianIndex, List<PedestrianBehaviour> pedestrianBehaviours)
```

### Parameters

<table><thead><tr><th width="261">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>pedestrianIndex</strong></td><td>The index of the pedestrian.</td></tr><tr><td><strong>pedestrianBehaviours</strong></td><td>An orderderd list of the new beheviours.</td></tr></tbody></table>

### Example

```csharp
using Gley.PedestrianSystem;
using Gley.PedestrianSystem.Internal;
using System.Collections.Generic;
using UnityEngine;

public class MyBehaviours : IBehaviourList
{
    public List<PedestrianBehaviour> GetBehaviours()
    {
        return new List<PedestrianBehaviour>
        {
                //order all behaviours 
                //the top one is the most important
                //only a behaviour can be active at the time
                new Dead(),
                new Hit(),
                new DestinationReached(),
                new StopAtCrossing(),
                new RunForever(1),
                new Crossing(),
                new Walk(),
        };
    }
}

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

    Pedestrian _selectedPedestrian;

    void Start()
    {
        API.Initialize(Player, 1, PedestrianPool);
    }

    public void SetNewBehaviours()
    {
        List<PedestrianBehaviour> newBehaviours = new MyBehaviours().GetBehaviours();

        // Assign the new behaviours list to the pedestrian 0
        API.SetPedestrianBehaviours(0, newBehaviours);
    }

    // Used for demonstration purposes.
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            SetNewBehaviours();
        }
    }
}
```
