# Instantiate

> Clones an entity.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## Instantiate(Entity)

Clones an entity.

```csharp
public Entity Instantiate(Entity srcEntity)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to clone.

### Returns

| Type                                                               | Description                           |
| ------------------------------------------------------------------ | ------------------------------------- |
| [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) | The Entity object for the new entity. |

### Remarks

The new entity has the same archetype and component values as the original; however, [ICleanupComponentData](/engine/7000.0/script-reference/unity/entities/icleanupcomponentdata.md) and [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md) components are removed from the clone.

If the source entity was converted from a prefab and thus has a [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) component, the entire group is cloned as a new set of entities. Components that are being cloned and contain references to entities that are also being cloned are properly remapped to the newly instantiated entities. **Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the entity. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

## Instantiate(Entity, NativeArray\<Entity>)

Makes multiple clones of an entity.

```csharp
public void Instantiate(Entity srcEntity, NativeArray<Entity> outputEntities)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to clone.**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): An array to receive the Entity objects of the root entity in each clone. The length of this array determines the number of clones.

### Remarks

The new entity has the same archetype and component values as the original, however cleanup and prefab tag components are removed from the clone.

If the source entity has a [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) component, the entire group is cloned as a new set of entities. Entity references on components that are being cloned to entities inside the set are remapped to the instantiated entities.

**Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the entity. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

## Instantiate(Entity, int, AllocatorHandle)

Makes multiple clones of an entity.

```csharp
public NativeArray<Entity> Instantiate(Entity srcEntity, int instanceCount, AllocatorManager.AllocatorHandle allocator)
```

### Parameters

**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to clone.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of entities to instantiate with the same components as the source entity.**** (\[AllocatorHandle]\(/engine/7000.0/script-reference/unity/collections/allocatormanager/allocatorhandle)): How the created native array should be allocated.

### Returns

| Type                                                                                      | Description                                                                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [NativeArray\<Entity>](/engine/7000.0/script-reference/unity/collections/nativearray1.md) | A \\\<a href="[https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray\_1.html"\\>NativeArray\\\</a\\](https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray_1.html"\\>NativeArray\\\</a\\)> of entities. |

### Remarks

The new entity has the same archetype and component values as the original, however cleanup and prefab tag components are removed from the clone.

If the source entity has a [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) component, the entire group is cloned as a new set of entities. Entity references on components that are being cloned to entities inside the set are remapped to the instantiated entities.

**Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the entity. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.

## Instantiate(NativeArray\<Entity>, NativeArray\<Entity>)

Clones a set of entities.

> **Warning:**
>
> **Deprecated.** This method will be removed in a future Entities release. If you wish to clone the full hierarchy of every entity in a given array, simply loop through the array to and invoke `EntityManager.Instantiate(Entity entity)` on each entity.

```csharp
public void Instantiate(NativeArray<Entity> srcEntities, NativeArray<Entity> outputEntities)
```

### Parameters

**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The set of entities to clone**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): the set of entities that were cloned. outputEntities.Length must match srcEntities.Length

### Remarks

The new entity has the same archetype and component values as the original, however cleanup and prefab tag components are removed from the clone.

Entity references on components that are being cloned to entities inside the set are remapped to the instantiated entities. This method overload ignores the [LinkedEntityGroup](/engine/7000.0/script-reference/unity/entities/linkedentitygroup.md) component, since the group of entities that will be cloned is passed explicitly.

**Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before creating the entity. No additional jobs can start before the method is finished. A sync point can cause a drop in performance because the ECS framework might not be able to use the processing power of all available cores.
