# DestroyEntity

> Records a command to destroy an entity.

## Definition

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

## DestroyEntity(Entity)

Records a command to destroy an entity.

```csharp
public void DestroyEntity(Entity e)
```

### Parameters

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

### Remarks

At playback, this command throws an error if the entity was destroyed between recording and playback, or if the entity has the [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md) tag.

## DestroyEntity(NativeArray\<Entity>)

Records a command to destroy a NativeArray of entities.

```csharp
public void DestroyEntity(NativeArray<Entity> entities)
```

### Parameters

**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The NativeArray of entities to destroy.

### Remarks

At playback, this command only runs if the entity count is greater than 0. This command throws an error if any of the entities were destroyed between recording and playback, or if any of the entities have the [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md) tag.

## DestroyEntity(EntityQuery, EntityQueryCaptureMode)

Records a command to destroy all entities matching a query.

```csharp
public void DestroyEntity(EntityQuery entityQuery, EntityQueryCaptureMode queryCaptureMode)
```

### Parameters

**** (\[EntityQuery]\(/engine/7000.0/script-reference/unity/entities/entityquery)): The query specifying the entities to destroy.**** (\[EntityQueryCaptureMode]\(/engine/7000.0/script-reference/unity/entities/entityquerycapturemode)): Controls when the entities matching `entityQuery` are computed and captured.

## DestroyEntity(EntityQuery)

Obsolete. Use [EntityCommandBuffer.DestroyEntity](/engine/7000.0/script-reference/unity/entities/entitycommandbuffer/destroyentity.md) instead.

> **Warning:**
>
> **Deprecated.** This method now takes an extra parameter to control when the query is evaluated. To preserve the current semantics, use EntityQueryCaptureMode.AtRecord (RemovedAfter Entities 2.0)

```csharp
public void DestroyEntity(EntityQuery entityQuery)
```

### Parameters

**** (\[EntityQuery]\(/engine/7000.0/script-reference/unity/entities/entityquery)): The query specifying the entities to destroy.
