# SetCallbackTarget(ReadOnlySpan<PhysicsBody>, object)

> Set the same Object that event callbacks will be sent to on a batch of bodies. Each body is assigned the callback target as PhysicsBody.callbackTarget would, and setting it to NULL removes it.

## Definition

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

## SetCallbackTarget(ReadOnlySpan\<PhysicsBody>, Object)

```csharp
public static int SetCallbackTarget(ReadOnlySpan<PhysicsBody> bodies, object callbackTarget)
```

### Parameters

**** (\[ReadOnlySpan\<PhysicsBody>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The bodies to set the callback target on.**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): The callback target to set on every body, or NULL to remove it.

### Returns

| Type                                                       | Description                                                                                                                     |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of bodies that were ignored (not set because the body was invalid). A single warning is logged when any are ignored. |

### Remarks

This is faster than setting [PhysicsBody.callbackTarget](/engine/6000.7/script-reference/unity/u2d/physics/physicsbody/callbacktarget.md) on each body.
