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

# InsertPositionAsTarget

### Description

Insert a Vector3 position (which has no waypoint associated) as a target for a pedestrian. Each position will have a unique negative number as a waypoint index, that can be used to identify it later on.

### Declaration

```csharp
public static int InsertPositionAsTarget(int pedestrianIndex, int currentPathPosition, Vector3 positionToInsert)
```

### 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>currentPathPosition</strong></td><td>The path index to insert the new position.</td></tr><tr><td><strong>positionToInsert</strong></td><td>The position in global coordinates to insert.</td></tr></tbody></table>

### Returns

**int -** A negative number representing the "waypointIndex" of the added position.

### 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 InsertPosition()
    {
        // Insert a position between the next 2 waypoints
        var curentWaypointPosition = API.GetCurrentWaypointPosition(0);
        var nextWaypointPosition = API.GetNextWaypointPosition(0);
        var newPosition = (curentWaypointPosition + neextWaypointPosition)/2;

        // Insert new position for pedestrian at index 0.
        // Insert position at index 1 in the path -> to be the next one
        int index = API.InsertPositionAsTarget(0, 1, newPosition);
        Debug.Log(index);
    }

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