# SetPath

> Define a path by its constituent points.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.Physics2DModule

## SetPath(int, Vector2\[])

Define a path by its constituent points.

```csharp
public void SetPath(int index, Vector2[] points)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the path to set.**** (\[Vector2\[]]\(/engine/6000.6/script-reference/unityengine/vector2)): An ordered array of the vertices (points) that define the path.

### Remarks

A *path* is a cyclic sequence of line segments between points that define the outline of the polygon. Because the polygon can have holes and discontinuous parts, its shape is not necessarily defined by a single path. For example, the polygon might actually be 3 separate paths.  In this case [PolygonCollider2D.SetPath](/engine/6000.6/script-reference/unityengine/polygoncollider2d/setpath.md) will be called 3 times, with an `index` of 0, 1 and 2. So `index` specifies which of these three collections of points are used.

Additional Resources: [PolygonCollider2D.pathCount](/engine/6000.6/script-reference/unityengine/polygoncollider2d/pathcount.md), [PolygonCollider2D.GetPath](/engine/6000.6/script-reference/unityengine/polygoncollider2d/getpath.md).

## SetPath(int, List\<Vector2>)

Define a path by its constituent points.

```csharp
public void SetPath(int index, List<Vector2> points)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the path to set.**** (\[List\<Vector2>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): An ordered list of the vertices (points) that define the path.

### Remarks

A *path* is a cyclic sequence of line segments between points that define the outline of the polygon. Because the polygon can have holes and discontinuous parts, its shape is not necessarily defined by a single path. For example, the polygon might actually be 3 separate paths.  In this case [PolygonCollider2D.SetPath](/engine/6000.6/script-reference/unityengine/polygoncollider2d/setpath.md) will be called 3 times, with an `index` of 0, 1 and 2. So `index` specifies which of these three collections of points are used.

Additional Resources: [PolygonCollider2D.pathCount](/engine/6000.6/script-reference/unityengine/polygoncollider2d/pathcount.md), [PolygonCollider2D.GetPath](/engine/6000.6/script-reference/unityengine/polygoncollider2d/getpath.md).

## SetPath(int, ReadOnlySpan\<Vector2>)

Define a path by its constituent points.

```csharp
public void SetPath(int index, ReadOnlySpan<Vector2> points)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the path to set.**** (\[ReadOnlySpan\<Vector2>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): An ordered span of the vertices (points) that define the path.

### Remarks

A *path* is a cyclic sequence of line segments between points that define the outline of the polygon. Because the polygon can have holes and discontinuous parts, its shape is not necessarily defined by a single path. For example, the polygon might actually be 3 separate paths.  In this case [PolygonCollider2D.SetPath](/engine/6000.6/script-reference/unityengine/polygoncollider2d/setpath.md) will be called 3 times, with an `index` of 0, 1 and 2. So `index` specifies which of these three collections of points are used.

Additional Resources: [PolygonCollider2D.pathCount](/engine/6000.6/script-reference/unityengine/polygoncollider2d/pathcount.md), [PolygonCollider2D.GetPath](/engine/6000.6/script-reference/unityengine/polygoncollider2d/getpath.md).
