# CreateEntity

> Creates an entity having the specified archetype.

## Definition

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

## CreateEntity(EntityArchetype)

Creates an entity having the specified archetype.

```csharp
public Entity CreateEntity(EntityArchetype archetype)
```

### Parameters

**** (\[EntityArchetype]\(/engine/7000.0/script-reference/unity/entities/entityarchetype)): The archetype for the new entity.

### Returns

| Type                                                               | Description                                              |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) | The Entity object that you can use to access the entity. |

### Remarks

The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.

**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.

## CreateEntity(ComponentType\[])

Creates an entity having components of the specified types.

```csharp
[ExcludeFromBurstCompatTesting("Takes managed array")]
public Entity CreateEntity(params ComponentType[] types)
```

### Parameters

**** (\[ComponentType\[]]\(/engine/7000.0/script-reference/unity/entities/componenttype)): The types of components to add to the new entity.

### Returns

| Type                                                               | Description                                              |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) | The Entity object that you can use to access the entity. |

### Remarks

The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.

**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.

## CreateEntity(ReadOnlySpan\<ComponentType>)

Creates an entity having components of the specified types.

```csharp
public Entity CreateEntity(ReadOnlySpan<ComponentType> types)
```

### Parameters

**** (\[ReadOnlySpan\<ComponentType>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The types of components to add to the new entity.

### Returns

| Type                                                               | Description                                              |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) | The Entity object that you can use to access the entity. |

### Remarks

The EntityManager creates the entity in the first available chunk with the matching archetype that has enough space.

**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.

## CreateEntity()

Creates an entity with no components.

```csharp
public Entity CreateEntity()
```

### Returns

| Type                                                               | Description                                              |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| [Entity](/engine/7000.0/script-reference/unity/entities/entity.md) | The Entity object that you can use to access the entity. |

### Remarks

The EntityManager creates the entity in the first available chunk with the archetype having no components.

**Important:** This method creates a sync point, which means that the EntityManager waits for all currently running jobs to complete before setting the component. 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.

## CreateEntity(EntityArchetype, NativeArray\<Entity>)

Creates a set of entities of the specified archetype.

```csharp
public void CreateEntity(EntityArchetype archetype, NativeArray<Entity> entities)
```

### Parameters

**** (\[EntityArchetype]\(/engine/7000.0/script-reference/unity/entities/entityarchetype)): The archetype defining the structure for the new entities.**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): An array to hold the Entity objects needed to access the new entities. The length of the array determines how many entities are created.

### Remarks

Fills the \<a href="[https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray\_1.html"\&gt;NativeArray\&lt;/a](https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray_1.html"\&gt;NativeArray\&lt;/a)> object assigned to the `entities` parameter with the Entity objects of the created entities. Each entity has the components specified by the [EntityArchetype](/engine/7000.0/script-reference/unity/entities/entityarchetype.md) object assigned to the `archetype` parameter. The EntityManager adds these entities to the [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) entity list. Use the Entity objects in the array for further processing, such as setting the component values.

## CreateEntity(EntityArchetype, int, AllocatorHandle)

Creates a set of entities of the specified archetype.

```csharp
public NativeArray<Entity> CreateEntity(EntityArchetype archetype, int entityCount, AllocatorManager.AllocatorHandle allocator)
```

### Parameters

**** (\[EntityArchetype]\(/engine/7000.0/script-reference/unity/entities/entityarchetype)): The archetype defining the structure for the new entities.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of entities to create with the specified archetype.**** (\[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 with the given archetype. |

### Remarks

Creates a \<a href="[https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray\_1.html"\&gt;NativeArray\&lt;/a](https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray_1.html"\&gt;NativeArray\&lt;/a)> of entities, each of which has the components specified by the [EntityArchetype](/engine/7000.0/script-reference/unity/entities/entityarchetype.md) object assigned to the `archetype` parameter. The EntityManager adds these entities to the [EntityManager.World](/engine/7000.0/script-reference/unity/entities/entitymanager/world.md) entity list.

## CreateEntity(EntityArchetype, int)

Creates a set of entities of the specified archetype.

```csharp
public void CreateEntity(EntityArchetype archetype, int entityCount)
```

### Parameters

**** (\[EntityArchetype]\(/engine/7000.0/script-reference/unity/entities/entityarchetype)): The archetype defining the structure for the new entities.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of entities to create with the specified archetype.

### Remarks

Unlike the other overloads, this does not create an array of Entity values. You don't always need the Entity value of a newly created entity because maybe you only need to access the entity through queries.
