ue-actor-component-arc…
Use this skill when working with Actor and component design in Unreal Engine. Triggers on:…
Use this skill when working with Mass Entity, MassEntity, Mass AI, MassProcessor, MassFragment, MassTag, MassObserver, MassSpawner, MassCrowd, Mass ECS, entity archetype, ForEachEntityChunk, FMassEntityQuery, FMassEntityManager, ISM crowd, or large-scale entity simulation in
$ npx -y skills add quodsoler/unreal-engine-skills --skill ue-mass-entity --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/ue-mass-entityContext preview
The summary Claude sees to decide when to auto-load this skill.
Use this skill when working with Mass Entity, MassEntity, Mass AI, MassProcessor, MassFragment, MassTag, MassObserver, MassSpawner, MassCrowd, Mass ECS, entity archetype, ForEachEntityChunk, FMassEntityQuery, FMassEntityManager, ISM crowd, or large-scale entity simulation in
name: ue-mass-entity description: "Use this skill when working with Mass Entity, MassEntity, Mass AI, MassProcessor, MassFragment, MassTag, MassObserver, MassSpawner, MassCrowd, Mass ECS, entity archetype, ForEachEntityChunk, FMassEntityQuery, FMassEntityManager, ISM crowd, or large-scale entity simulation in Unreal Engine. See references/mass-entity-patterns.md for processor and observer templates. See references/mass-fragment-reference.md for built-in fragment types." metadata: version: 1.0.0
You are an expert in Unreal Engine's Mass Entity framework -- an archetype-based Entity Component System (ECS) designed for high-performance simulation of thousands of entities using cache-friendly data layouts and parallel processing.
Before proceeding, read `.agents/ue-project-context.md` to determine:
Ask the developer: 1. What kind of entities are being simulated? (crowds, projectiles, traffic, wildlife, custom) 2. What data does each entity carry? (position, velocity, health, custom state) 3. Are entities visualized? If so, what LOD strategy? (ISM, skeletal, actor promotion) 4. Is this multiplayer? If so, which entities replicate? 5. How many entities at peak? (hundreds vs. tens of thousands)
---
Mass Entity uses an archetype ECS model where entity composition determines memory layout:
| Concept | Class Base | Purpose | |---------|-----------|---------| | Entity | `FMassEntityHandle` | 8-byte identity handle (Index + SerialNumber) | | Fragment | `FMassFragment` | Per-entity mutable data (position, velocity, health) | | Tag | `FMassTag` | Zero-size boolean marker for filtering | | Shared Fragment | `FMassSharedFragment` | Per-archetype mutable data | | Const Shared Fragment | `FMassConstSharedFragment` | Per-archetype immutable data (mesh params) | | Chunk Fragment | `FMassChunkFragment` | Per-memory-chunk data (custom chunk-level state) | | Archetype | `FMassArchetypeHandle` | Unique combination of fragment/tag types |
**Why archetypes matter:** Entities with identical fragment/tag composition share the same archetype. All fragments of the same type within a chunk are stored contiguously, enabling cache-friendly iteration over thousands of entities per frame.
---
All types require `USTRUCT()` with `GENERATED_BODY()`:
// Per-entity mutable data
USTRUCT()
struct FHealthFragment : public FMassFragment
{
GENERATED_BODY()
float Current = 100.f;
float Max = 100.f;
};
// Zero-size marker — no data members
USTRUCT()
struct FDeadTag : public FMassTag
{
GENERATED_BODY()
};
// Shared across all entities in an archetype (mutable)
USTRUCT()
struct FTeamSharedFragment : public FMassSharedFragment
{
GENERATED_BODY()
int32 TeamID = 0;
};**Chunk fragments** (`FMassChunkFragment`) store per-memory-chunk state shared across all entities in a chunk. Note: `FMassRepresentationLODFragment` inherits from `FMassFragment` (per-entity), not `FMassChunkFragment`. **Const shared fragments** (`FMassConstSharedFragment`) are immutable after archetype creation -- use for configuration data like `FMassRepresentationParameters`. See `references/mass-fragment-reference.md` for built-in types.
---
The entity manager is NOT a `UObject` -- it is a struct (`TSharedFromThis<FMassEntityManager>`, `FGCObject`). Access it through `UMassEntitySubsystem` (a `UWorldSubsystem`):
UMassEntitySubsystem* MassSubsystem = GetWorld()->GetSubsystem<UMassEntitySubsystem>(); FMassEntityManager& EntityManager = MassSubsystem->GetMutableEntityManager(); // const ref: MassSubsystem->GetEntityManager()
// One-shot creation
FMassEntityHandle Entity = EntityManager.CreateEntity(ArchetypeHandle);
// With shared fragments
FMassArchetypeSharedFragmentValues SharedValues;
FMassEntityHandle Entity = EntityManager.CreateEntity(ArchetypeHandle, SharedValues);
// Two-phase (reserve then build)
FMassEntityHandle Handle = EntityManager.ReserveEntity();
EntityManager.BuildEntity(Handle, ArchetypeHandle);
// Batch creation (thousands at once)
// BatchCreateEntities returns TSharedRef<FEntityCreationContext> — retain it until
// observer processors should fire (dropping it early suppresses observer execution).
TArray<FMassEntityHandle> Entities;
TSharedRef<FEntityCreationContext> CreationContext =
EntityManager.BatchCreateEntities(ArchetypeHandle, 5000, Entities);
// Destruction
EntityManager.DestroyEntity(Handle);
EntityManager.BatchDestroyEntities(EntityArray);`FMassEntityHandle::IsSet()` (aliased as `IsValid()`) only checks non-zero Index/SerialNumber -- it does NOT verify the entity exists. Always use the entity manager:
EntityManager.IsEntityValid(Handle) // entity exists EntityManager.IsEntityBuilt(Handle) // fully constructed EntityManager.IsEntityActive(Handle) // active in simulation
EntityManager.AddFragmentToEntity(Handle, FHealthFragment::StaticStruct()); EntityManager.RemoveFragmentFromEntity(Handle, FHealthFragment::StaticStruct()); EntityManager.AddTagToEntity(Handle, FDeadTag::StaticStruct()); EntityManager.RemoveTagFromEntity(Handle, FDeadTag::StaticStruct()); EntityManager.SwapTagsForEntity(Handle, FOldTag::StaticStruct(), FNewTag::StaticStruct());
---
Processors iterate over entities matching a query each frame. Subclass `UMassProcessor` (abstract), override `ConfigureQueries()` and `Execute()`:
UCLASS()
class UMyMovementProcessor : public UMassProcessor
{
GENERATED_BODY()
public:
UMyMovemA collection of 27 AI agent skills for Unreal Engine C++ development. Built for game developers who want AI coding agents to help write correct, production-quality UE5 C++ code.
Use this skill when working with Actor and component design in Unreal Engine. Triggers on:…
Use this skill when implementing AI, AIController, behavior tree, blackboard, AI perception,…
Use this skill when working with Unreal Engine animation: AnimInstance, montage playback,…
Use this skill when working with Unreal Engine async operations, threading, parallel…
Use this skill when working with audio, sound, music, UAudioComponent, PlaySoundAtLocation,…
Use this skill when working with character movement, CharacterMovementComponent, CMC,…