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

# RemovePath

### Description

Remove a predefined path for a pedestrian. The pedestrian will then behave like a normal one and will be added and removed by the pooling system.

### Declaration

```csharp
 public static void RemovePath(int pedestrianIndex)
```

### 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></tbody></table>

### Example

```csharp
using Gley.PedestrianSystem;
using System.Collections.Generic;
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()
    {
        API.Initialize(player, 1, pedestrianPool);
        PedestrianEvents.onDestinationReached += DestinationReached;
    }

    public void AddPathToPedestrian()
    {
        // Get the path from start to end.
        Vector3 startPosition = new Vector3(0, 0, 0);
        Vector3 endPosition = new Vector3(0, 0, 350);
        List<int> path = API.GetPath(startPosition, endPosition, PedestrianTypes.Normal);

        if (path.Count > 0)
        {
            // Assign the path to the pedestrian with index 0.
            API.SetPath(0, path);
        }
        else
        {
            Debug.Log("No path found");
        }
    }

    private void DestinationReached(int pedestrianIndex)
    {
        // When pedestrian 0 reaches the destination, remove the path and continue as a normal pedestrian.
        if (pedestrianIndex == 0)
        {
            API.RemovePath(0);
        }
    }

    private void OnDestroy()
    {
        //don't forget to remove the events
        PedestrianEvents.onDestinationReached -= DestinationReached;
    }

    // For demonstration purposes.
    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            AddPathToPedestrian();
        }
    }
}

```
