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

# StopBehavior

### Description

Stop executing a specific behaviour.

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 StopBehaviour<T>(int pedestrianIndex) where T : PedestrianBehaviour
```

### Parameters

<table><thead><tr><th width="261">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>T</strong></td><td>The behaviour to stop. An implementation of PedestrianBehaviour abstract class.</td></tr><tr><td><strong>pedestrianIndex</strong></td><td>The index of the pedestrian.</td></tr></tbody></table>

### Example

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

public class YourBehaviourScript : PedestrianBehaviour
{
    internal override void Execute(float turnAngle, float moveSpeed)
    {
        // Create your behaviour here.
    }

    internal override void OnDestroy()
    {
        // Destroy objects here if required.
    }
}


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

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

    public void StartRunning()
    {
        API.StartBehavior<YourBehaviourScript>(0);
    }

    public void StopRunning()
    {
        API.StopBehaviour<YourBehaviourScript>(0);
    }

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