entity-command-buffer

Record structural entity operations in Unity DOTS jobs for safe playback.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill entity-command-buffer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: entity-command-buffer
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/entity-command-buffer
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill entity-command-buffer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Structural changes in Unity DOTS (like adding/removing components or instantiating/destroying entities) cannot be safely performed from within parallel jobs, so entities can end up in invalid states or cause runtime errors.

Core Features & Use Cases

  • Record structural changes during jobs: Queue AddComponent, RemoveComponent, Instantiate, and DestroyEntity operations without performing them immediately.
  • Play back at the correct frame boundary: Use the appropriate ECB system (e.g., BeginSimulationEntityCommandBufferSystem) so changes are applied safely on the main thread after simulation timing.
  • Deterministic parallel playback: Use ECB.ParallelWriter with a proper sort key (chunk index) to ensure stable, predictable replay order across workers.

Quick Start

Ask your AI to show how to record entity instantiation and component setup inside a parallel IJobEntity using BeginSimulationEntityCommandBufferSystem and a chunk index sort key.

Frequently Asked Questions about entity-command-buffer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make structural changes to entities from within a Unity DOTS parallel job?

To make structural changes from within a Unity DOTS parallel job, record operations like AddComponent or DestroyEntity using an EntityCommandBuffer. This queues the changes so they can be safely replayed on the main thread after the job finishes, preventing invalid entity states.

What is an EntityCommandBuffer used for in Unity DOTS?

An EntityCommandBuffer in Unity DOTS is used to record structural entity operations such as Instantiate and RemoveComponent during job execution. It defers these changes so they can be safely applied at a specific frame boundary, preserving deterministic behavior and preventing runtime errors.

How do I ensure deterministic playback when recording structural changes across multiple workers?

To ensure deterministic playback across parallel workers, use the EntityCommandBuffer.ParallelWriter and provide a stable sort key, such as the chunk index. This guarantees a predictable and stable replay order when the deferred structural changes are finally applied.

Why does destroying entities directly inside an IJobEntity cause runtime errors in Unity DOTS?

Destroying entities directly inside an IJobEntity causes runtime errors because structural changes invalidate active entity iteration and chunk data. You must defer the destruction by recording it to an EntityCommandBuffer, which safely applies the changes after the job completes.

Can I use an EntityCommandBuffer with Burst-compiled jobs in Unity DOTS?

Yes, you can use an EntityCommandBuffer with Burst-compiled jobs in Unity DOTS. You need to obtain the ECB from an EntityCommandBufferSystem singleton and use its AsParallelWriter method to safely record structural changes from within the Burst job.

When should I play back structural changes recorded in an EntityCommandBuffer?

You should play back structural changes recorded in an EntityCommandBuffer at the correct frame boundary using the appropriate EntityCommandBufferSystem, such as BeginSimulationEntityCommandBufferSystem. This ensures changes are applied safely on the main thread after simulation timing.