# Clone

> Clear any existing proxies and clone all PhysicsShape found in the specified PhysicsWorld. Each proxy created will have a user-handle assigned as _physicsHandle. This means you can get the referenced shape by using PhysicsShape.

## Definition

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

## Clone(PhysicsWorld, QueryFilter, bool)

Clear any existing proxies and clone all [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) found in the specified [PhysicsWorld](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld.md). Each proxy created will have a user-handle assigned as [\_physicsHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape/physicshandle.md). This means you can get the referenced shape by using [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape/ctor.md).

```csharp
public int Clone(PhysicsWorld world, PhysicsQuery.QueryFilter filter, bool destroyExistingProxies = true)
```

### Parameters

**** (\[PhysicsWorld]\(/engine/6000.6/script-reference/unity/u2d/physics/physicsworld)): The world to find the [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) in.**** (\[QueryFilter]\(/engine/6000.6/script-reference/unity/u2d/physics/physicsquery/queryfilter)): The filter to control what proxies are created.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Controls if any existing proxies are destroyed before cloning from the specified world. If false, care should be taken that any existing proxies refer to [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) otherwise a mix of user-handles will be present.

### Returns

| Type                                                       | Description                   |
| ---------------------------------------------------------- | ----------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | How many proxies were cloned. |

## Clone(PhysicsWorld, QueryFilter, PhysicsAABB, bool)

Clear any existing proxies and clone any [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) found in the specified [PhysicsWorld](/engine/6000.6/script-reference/unity/u2d/physics/physicsworld.md) overlapping the specified [PhysicsAABB](/engine/6000.6/script-reference/unity/u2d/physics/physicsaabb.md). Each proxy created will have a user-handle assigned as [\_physicsHandle](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape/physicshandle.md). This means you can get the referenced shape by using [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape/ctor.md).

```csharp
public int Clone(PhysicsWorld world, PhysicsQuery.QueryFilter filter, PhysicsAABB aabb, bool destroyExistingProxies = true)
```

### Parameters

**** (\[PhysicsWorld]\(/engine/6000.6/script-reference/unity/u2d/physics/physicsworld)): The world to find the [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) in.**** (\[QueryFilter]\(/engine/6000.6/script-reference/unity/u2d/physics/physicsquery/queryfilter)): The filter to control what proxies are created.**** (\[PhysicsAABB]\(/engine/6000.6/script-reference/unity/u2d/physics/physicsaabb)): The AABB used to discover [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) in the specified world. If the AABB size is size (default) then the whole world will be discovered.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Controls if any existing proxies are destroyed before cloning from the specified world. If false, care should be taken that any existing proxies refer to [PhysicsShape](/engine/6000.6/script-reference/unity/u2d/physics/physicsshape.md) otherwise a mix of user-handles will be present.

### Returns

| Type                                                       | Description                   |
| ---------------------------------------------------------- | ----------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | How many proxies were cloned. |
