# PhysicsChain

> A dedicated shape that produces a chain of shapes connected together to produce a continuous surface. Chain shapes provide a smooth, continuous surface that will not produce "ghost" collisions. A PhysicsChain is automatically destroyed when the body it is in is destroyed. A PhysicsChain cannot exist unattached from a body. This will produce shapes of type PhysicsShape.ShapeType.ChainSegment. Chains are one-sided. A chain has no mass therefore should ideally be used on static bodies. A chain can have a counter-clockwise winding order (normal points right of segment direction). A chain is either a loop or open. A chain must have at least 4 points. The distance between any two points must be greater than PhysicsWorld.linearSlop. A chain should not self intersect (this is not validated). An open chain has no collision on the first and final edge. You may overlap two open chains on their first three and/or last three points to get smooth collision.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEngine.LowLevelPhysics2D](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d.md)
* **Assembly:** UnityEngine.Physics2DModule
* **Implements:** [IEquatable\<PhysicsChain>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public readonly struct PhysicsChain : IEquatable<PhysicsChain>
```

## Properties

| Property                                                                                                           | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [aabb](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/aabb.md)                         | Get the world AABB that bounds this chain. The bounds of the shape is inflated slightly due to speculative collision detection. The inflation is smaller on Static shape types however it is not zero due to time-of-impact collision detection. If an exact AABB is required then you can retrieve that via the shape geometry.                                                                                       |
| [body](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/body.md)                         | The body which the chain is attached to.                                                                                                                                                                                                                                                                                                                                                                               |
| [bounciness](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/bounciness.md)             | The bounciness of the chain. Usually this is within the range \[0, 1]. Values higher than 1 will result in energy being added which can lead to an unstable simulation.                                                                                                                                                                                                                                                |
| [bouncinessMixing](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/bouncinessmixing.md) | Defines the method used when mixing the bounciness values of two shapes to form a shape contact. This is assigned to the current [PhysicsShape.surfaceMaterial](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsshape/surfacematerial-1.md).                                                                                                                                                      |
| [callbackTarget](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/callbacktarget.md)     | Get/Set the Object that callbacks for the shapes owned by this chain will be sent to. Care should be taken with any Object assigned as a callback target that isn't a [Object](/engine/6000.3/script-reference/unityengine/object.md) as this assignment will not in itself keep the object alive and can be garbage collected. To avoid this, you should have at least a single reference to the object in your code. |
| [friction](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/friction.md)                 | The friction of the owned chain shapes. Usually this is within the range \[0, 1]. Values higher than 1 will result in energy being added which can lead to an unstable simulation.                                                                                                                                                                                                                                     |
| [frictionMixing](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/frictionmixing.md)     | Defines the method used when mixing the friction values of two shapes to form a shape contact. This is assigned to the current [PhysicsShape.surfaceMaterial](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsshape/surfacematerial-1.md).                                                                                                                                                        |
| [isOwned](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/isowned.md)                   | Get if the chain is owned. See [PhysicsChain.SetOwner](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/setowner.md).                                                                                                                                                                                                                                                                        |
| [isValid](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/isvalid.md)                   | Check if the shape is valid.                                                                                                                                                                                                                                                                                                                                                                                           |
| [ownerUserData](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/owneruserdata.md)       | Get [PhysicsUserData](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsuserdata.md) that can be used for any purpose, typically by the owner only.                                                                                                                                                                                                                                                 |
| [segmentCount](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/segmentcount.md)         | Get the number of Chain segments that this chain has created and owns. See [PhysicsShape.ShapeType.ChainSegment](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsshape/shapetype/chainsegment.md).                                                                                                                                                                                                |
| [userData](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/userdata.md)                 | Get/Set [PhysicsUserData](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsuserdata.md) that can be used for any purpose. The physics system doesn't use this data, it is entirely for custom use.                                                                                                                                                                                                 |
| [world](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/world.md)                       | Get the world the chain is attached to.                                                                                                                                                                                                                                                                                                                                                                                |

## Methods

| Method                                                                                                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CastRay](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/castray.md)                   | Check if a ray intersects the chain. See [PhysicsQuery.CastResult](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsquery/castresult.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [CastShape](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/castshape.md)               | Calculate if a cast shape intersects the chain. See [PhysicsQuery.CastShapeInput](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsquery/castshapeinput.md) and [PhysicsQuery.CastResult](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsquery/castresult.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [ClosestPoint](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/closestpoint.md)         | Calculate the closest point on this chain to the specified point.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [Destroy](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/destroy.md)                   | Destroy the [PhysicsChain](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain.md) and all the [PhysicsShape.ShapeType.ChainSegment](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsshape/shapetype/chainsegment.md) it owns. If the object is owned with [PhysicsChain.SetOwner](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/setowner.md) then you must provide the owner key it returned. Failing to do so will return a warning and the chain will not be destroyed. The lifetime of the specified owner object is not linked to this chain i.e. this chain will still be owned by the owner object, even if it is destroyed. This is the only way to destroy shapes of type [PhysicsShape.ShapeType.ChainSegment](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsshape/shapetype/chainsegment.md) if they were created by a [PhysicsChain](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain.md). |
| [GetOwner](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/getowner.md)                 | Get the owner object associated with this chain as specified using [PhysicsChain.SetOwner](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/setowner.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [GetSegmentIndex](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/getsegmentindex.md)   | Get the index of the specified Chain Segment PhysicsShape.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [GetSegments](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/getsegments.md)           | Get all the Chain segments that this chain has created and owns.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [SetOwner](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/setowner.md)                 | Set the (optional) owner object associated with this chain and return an owner key that must be specified when destroying the shape with [PhysicsChain.Destroy](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/destroy.md). The physics system provides access to all objects, including the ability to destroy them so this feature can be used to stop accidental destruction of objects that are owned by other objects. You can only set the owner once, multiple attempts will produce a warning. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner.                                                                                                                                                                                                                                                                                               |
| [SetOwnerUserData](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/setowneruserdata.md) | Set [PhysicsUserData](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicsuserdata.md) that can be used for any purpose, typically by the owner only.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

## Static Methods

| Method                                                                                         | Description                                                                                      |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| [Create](/engine/6000.3/script-reference/unityengine/lowlevelphysics2d/physicschain/create.md) | Create a Chain of multiple shapes attached to the specified body which itself is within a world. |
