# SetOwnerUserData

> Set PhysicsUserData that can be used for any purpose, typically by the owner only.

## Definition

* **Type:** Method
* **Namespace:** [Unity.U2D.Physics](/engine/6000.7/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

## SetOwnerUserData(PhysicsUserData, int)

Set [PhysicsUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata.md) that can be used for any purpose, typically by the owner only.

```csharp
public void SetOwnerUserData(PhysicsUserData physicsUserData, int ownerKey = 0)
```

### Parameters

**** (\[PhysicsUserData]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata)): The user data to set.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Optional owner key returned when using [PhysicsBody.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/setowner.md).

## SetOwnerUserData(ReadOnlySpan\<PhysicsBody>, ReadOnlySpan\<PhysicsUserData>, int)

Set [PhysicsUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata.md) on a batch of bodies that can be used for any purpose, typically by the owner only. The bodies and userDatas spans must be the same length; bodies\[n] receives userDatas\[n].

```csharp
public static void SetOwnerUserData(ReadOnlySpan<PhysicsBody> bodies, ReadOnlySpan<PhysicsUserData> userDatas, int ownerKey = 0)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsBody>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The bodies to set the owner user data on.**** (\[ReadOnlySpan\<PhysicsUserData>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The user data to set, one entry per body.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Optional owner key returned when using [PhysicsBody.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/setowner.md).

## SetOwnerUserData(ReadOnlySpan\<PhysicsBody>, PhysicsUserData, int)

Set the same [PhysicsUserData](/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata.md) on a batch of bodies that can be used for any purpose, typically by the owner only.

```csharp
public static void SetOwnerUserData(ReadOnlySpan<PhysicsBody> bodies, PhysicsUserData physicsUserData, int ownerKey = 0)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsBody>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The bodies to set the owner user data on.**** (\[PhysicsUserData]\(/engine/6000.7/script-reference/unity/u2d/physics/physicsuserdata)): The user data to set on every body.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Optional owner key returned when using [PhysicsBody.SetOwner](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/setowner.md).
