# attachedRigidbody

> The Rigidbody2D attached to the Collider2D.

## Definition

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

```csharp
public Rigidbody2D attachedRigidbody { get; }
```

### Remarks

[Collider2D](/engine/6000.0/script-reference/unityengine/collider2d.md) are automatically attached to a [Rigidbody2D](/engine/6000.0/script-reference/unityengine/rigidbody2d.md) on the same [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) as the [Collider2D](/engine/6000.0/script-reference/unityengine/collider2d.md) or if none is present then on a [Rigidbody2D](/engine/6000.0/script-reference/unityengine/rigidbody2d.md) on the nearest parent [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md).  The property will be null if no [Rigidbody2D](/engine/6000.0/script-reference/unityengine/rigidbody2d.md) is attached.  In this case, the [Collider2D](/engine/6000.0/script-reference/unityengine/collider2d.md) is attached to a hidden body known as the ground body that lives at the world origin as is set to be [RigidbodyType2D.Static](/engine/6000.0/script-reference/unityengine/rigidbodytype2d/static.md).  No reference to this hidden body is available however.

Additional Resources: [Rigidbody2D](/engine/6000.0/script-reference/unityengine/rigidbody2d.md), [RigidbodyType2D](/engine/6000.0/script-reference/unityengine/rigidbodytype2d.md).

### Examples

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

public class ExampleClass : MonoBehaviour
{
    public Vector2 force = Vector2.up;

    void Start()
    {
        // Apply a force to the rigidbody attached to the collider.
        GetComponent<Collider2D>().attachedRigidbody.AddForce(force);
    }
}
```
