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

# SetPedestrianOffset

### Description

Set the deviation between the waypoint that the pedestrian is using.

A pedestrian path (sidewalk) has a width and a pedestrian can follow any path from one side of the sidewalk to the other. with an offset of -1 the pedestrian will use one side of the sidewalk and with an offset of 1 will use the other side. An offset of 0 means that it will go to the center of the sidewalk. &#x20;

### Declaration

```csharp
public static void SetPedestrianOffset(int pedestrianIndex, float offset)
```

### 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>offset</strong></td><td>[-1,1] -1 ->left side of the sidewalk, 1 -> right side of the sidewalk</td></tr></tbody></table>

### 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()
    {
        API.Initialize(Player, 1, PedestrianPool);
    }

    public void ChangeOffset()
    {
        API.SetPedestrianOffset(0, Random.Range(-1f, 1f));  
    }

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