# SetShapeAdjacentVertices(int, bool, bool, Vector2, Vector2)

> Sets the adjacent vertices of a shape.

## Definition

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

```csharp
public void SetShapeAdjacentVertices(int shapeIndex, bool useAdjacentStart, bool useAdjacentEnd, Vector2 adjacentStart, Vector2 adjacentEnd)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the shape to be modified that is stored the [PhysicsShapeGroup2D](/engine/6000.0/script-reference/unityengine/physicsshapegroup2d.md).**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Sets the [PhysicsShape2D.useAdjacentStart](/engine/6000.0/script-reference/unityengine/physicsshape2d/useadjacentstart.md) property of the selected shape.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Sets the [PhysicsShape2D.useAdjacentEnd](/engine/6000.0/script-reference/unityengine/physicsshape2d/useadjacentend.md) property of the selected shape.**** (\[Vector2]\(/engine/6000.0/script-reference/unityengine/vector2)): Sets the [PhysicsShape2D.adjacentStart](/engine/6000.0/script-reference/unityengine/physicsshape2d/adjacentstart.md) property of the selected shape.**** (\[Vector2]\(/engine/6000.0/script-reference/unityengine/vector2)): Sets the [PhysicsShape2D.adjacentEnd](/engine/6000.0/script-reference/unityengine/physicsshape2d/adjacentend.md) property of the selected shape.

### Remarks

**NOTE**: Calling this on a [PhysicsShape2D](/engine/6000.0/script-reference/unityengine/physicsshape2d.md) that does not have a [shapeType](/engine/6000.0/script-reference/unityengine/physicsshape2d/shapetype.md) of [PhysicsShapeType2D.Edges](/engine/6000.0/script-reference/unityengine/physicsshapetype2d/edges.md) will result in an exception being thrown.

### Examples

```csharp
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;

public class Example : MonoBehaviour
{
    void Start()
    {
        // Create a shape group.
        var shapeGroup = new PhysicsShapeGroup2D();

        // Add a list of Edges.
        var shapeIndex = shapeGroup.AddEdges
            (
                vertices: new List<Vector2>
                {
                    new Vector2(-4f, 0f),
                    new Vector2(-2f, -0.5f),
                    new Vector2(0f, 0f),
                    new Vector2(2f, -0.5f),
                    new Vector2(4f, 0f),
                },

                edgeRadius: 0.5f,

                useAdjacentStart: true,
                useAdjacentEnd: true,
                adjacentStart: new Vector2(-5f, -1f),
                adjacentEnd: new Vector2(6f, 2f)
            );

        // Fetch the actual shape created.
        var physicsShape = shapeGroup.GetShape(shapeIndex);

        // Validate what we created.
        Assert.AreEqual(PhysicsShapeType2D.Edges, physicsShape.shapeType);
        Assert.AreApproximatelyEqual(0.5f, physicsShape.radius);
        Assert.AreEqual(5, physicsShape.vertexCount);
        Assert.IsTrue(physicsShape.useAdjacentStart);
        Assert.IsTrue(physicsShape.useAdjacentEnd);
        Assert.AreEqual(new Vector2(-5f, -1f), physicsShape.adjacentStart);
        Assert.AreEqual(new Vector2(6f, 2f), physicsShape.adjacentEnd);

        // Set the adjacent vertices.
        shapeGroup.SetShapeAdjacentVertices(
            shapeIndex,
            useAdjacentStart: true,
            useAdjacentEnd: true,
            adjacentStart: new Vector2(-10f, -5f),
            adjacentEnd: new Vector2(12f, 3f));

        // Fetch the updated shape.
        physicsShape = shapeGroup.GetShape(shapeIndex);

        // Validate what we updated.
        Assert.IsTrue(physicsShape.useAdjacentStart);
        Assert.IsTrue(physicsShape.useAdjacentEnd);
        Assert.AreEqual(new Vector2(-10f, -5f), physicsShape.adjacentStart);
        Assert.AreEqual(new Vector2(12f, 3f), physicsShape.adjacentEnd);
    }
}
```
