# RemoveComponent

> Records a command to remove component of type T from an entity.

## Definition

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

## RemoveComponent\<T>(int, Entity)

Records a command to remove component of type T from an entity.

```csharp
public void RemoveComponent<T>(int sortKey, Entity e)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The [ChunkIndexInQuery](/engine/7000.0/script-reference/unity/entities/chunkindexinquery.md) provided by [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) is an appropriate value to use for this parameter. In an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to have the component removed.

### Remarks

At playback, it's not an error if the entity doesn't have component T. Will throw an error if this entity is destroyed before playback, or if T is type Entity or [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md).

## RemoveComponent\<T>(int, NativeArray\<Entity>)

Records a command to remove component of type T from a NativeArray of entities.

```csharp
public void RemoveComponent<T>(int sortKey, NativeArray<Entity> entities)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The [ChunkIndexInQuery](/engine/7000.0/script-reference/unity/entities/chunkindexinquery.md) provided by [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) is an appropriate value to use for this parameter. In an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The NativeArray of entities to have the component removed.

### Remarks

At playback, it's not an error if any entity doesn't have component T. Will throw an error if one of these entities is destroyed before playback, or if T is type Entity or [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md).

## RemoveComponent(int, Entity, ComponentType)

Records a command to remove a component from an entity.

```csharp
public void RemoveComponent(int sortKey, Entity e, ComponentType componentType)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The [ChunkIndexInQuery](/engine/7000.0/script-reference/unity/entities/chunkindexinquery.md) provided by [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) is an appropriate value to use for this parameter. In an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to have the component removed.**** (\[ComponentType]\(/engine/7000.0/script-reference/unity/entities/componenttype)): The type of component to remove.

### Remarks

At playback, it's not an error if the entity doesn't have the component type. Will throw an error if this entity is destroyed before playback, or if the component type is Entity or [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md).

## RemoveComponent(int, NativeArray\<Entity>, ComponentType)

Records a command to remove one or more components from a NativeArray of entities.

```csharp
public void RemoveComponent(int sortKey, NativeArray<Entity> entities, ComponentType componentType)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The [ChunkIndexInQuery](/engine/7000.0/script-reference/unity/entities/chunkindexinquery.md) provided by [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) is an appropriate value to use for this parameter. In an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The NativeArray of entities to have the component removed.**** (\[ComponentType]\(/engine/7000.0/script-reference/unity/entities/componenttype)): The type of component to remove.

### Remarks

At playback, it's not an error if any entity doesn't have the component type. Will throw an error if one of these entities is destroyed before playback, or if the component type is Entity or [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md).

## RemoveComponent(int, Entity, ComponentTypeSet)

Records a command to remove one or more components from an entity.

```csharp
public void RemoveComponent(int sortKey, Entity e, in ComponentTypeSet typeSet)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The [ChunkIndexInQuery](/engine/7000.0/script-reference/unity/entities/chunkindexinquery.md) provided by [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) is an appropriate value to use for this parameter. In an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.**** (\[Entity]\(/engine/7000.0/script-reference/unity/entities/entity)): The entity to have the components removed.**** (\[ComponentTypeSet]\(/engine/7000.0/script-reference/unity/entities/componenttypeset)): The types of components to remove.

### Remarks

At playback, it's not an error if the entity doesn't have one of the component types. Will throw an error if this entity is destroyed before playback, or if any of the component types are Entity or [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md).

## RemoveComponent(int, NativeArray\<Entity>, ComponentTypeSet)

Records a command to remove one or more components from a NativeArray of entities.

```csharp
public void RemoveComponent(int sortKey, NativeArray<Entity> entities, in ComponentTypeSet typeSet)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A unique index for each set of commands added to this EntityCommandBuffer across all parallel jobs writing commands to this buffer. The [ChunkIndexInQuery](/engine/7000.0/script-reference/unity/entities/chunkindexinquery.md) provided by [IJobEntity](/engine/7000.0/script-reference/unity/entities/ijobentity.md) is an appropriate value to use for this parameter. In an [IJobChunk](/engine/7000.0/script-reference/unity/entities/ijobchunk.md) pass the 'unfilteredChunkIndex' value from IJobChunk.Execute.**** (\[NativeArray\<Entity>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The NativeArray of entities to have components removed.**** (\[ComponentTypeSet]\(/engine/7000.0/script-reference/unity/entities/componenttypeset)): The types of components to remove.

### Remarks

At playback, it's not an error if any entity doesn't have one of the component types. Will throw an error if one of these entities is destroyed before playback, or if any of the component types are Entity or [Prefab](/engine/7000.0/script-reference/unity/entities/prefab.md).
