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

# GetWaypointFromIndex

### Description

Returns the Waypoint object for a given waypoint index.

### Declaration&#x20;

```csharp
public static Waypoint GetWaypointFromIndex(int waypointIndex)
```

### Parameters

<table><thead><tr><th width="188">Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>waypointIndex</strong></td><td>The index of the waypoint.</td></tr></tbody></table>

### Returns

**Waypoint -** The Waypoint object at the index position inside the waypoint list.

### Example

```csharp
using Gley.TrafficSystem;
using Gley.TrafficSystem.Internal;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
    //a reference to vehicle pool and player assigned in inspector
    public VehiclePool vehiclePool;
    public Transform player;

    void Start()
    {
        API.Initialize(player, 20, vehiclePool);
    }

    public void CreatePath()
    {
        //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, VehicleTypes.Car);

        foreach (int pathIndex in path)
        {
            Waypoint waypoint = API.GetWaypointFromIndex(pathIndex);
            Debug.Log(waypoint.name + " " + waypoint.position);
        }
    }
}

```
