# Attach custom data to LowLevelPhysics2D API objects

> Attach values and physics masks to physics objects so you can fetch them later.

> **Note:**
>
> This documentation is about writing C# scripts using the `LowLevelPhysics2D` API. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to [2D physics](/engine/6000.3/manual/unity2d/2d-physics.md.md) instead.

To attach custom data to an object you create using the `LowLevelPhysics2D` API, use the `PhysicsUserData` type.

You can attach data to the following types:

* `World`
* `Body`
* `Shape`
* `Chain`
* `Joint`

Follow these steps:

1. Create a `PhysicsUserData` instance and populate it with your custom fields. For example:

   ```csharp
   PhysicsUserData physicsUserData = new PhysicsUserData
       {
           customObject = this,
           customBool = true,
           customFloat = 123.4f,
           customInt = 567,
           customPhysicsMask = PhysicsMask.All
       };
   ```

2. Assign a `PhysicsUserData` instance to the `userData` property of the physics object. For example, to assign the custom data to a shape:

   ```csharp
   myShape.userData = physicsUserData;
   ```

3. To fetch the data, for example when you [detect a collision](/engine/6000.3/manual/unity2d/2d-physics-api/interactions/collision-handle.md), get the `userData` property of the physics object. For example:

   ```csharp
   Debug.Log(myShape.userData.intValue);
   ```

## Additional resources

* [Collisions and interactions in the LowLevelPhysics2D API](/engine/6000.3/manual/unity2d/2d-physics-api/interactions.md)
* [PhysicsCore2D repository](https://github.com/Unity-Technologies/PhysicsExamples2D/tree/master) on GitHub
