All skills
quodsoler avatar

/ue-mass-entity

@f3742d7

Use when writing or debugging Mass Entity ECS code in Unreal Engine C++ — processors, queries, fragments, tags, observers, traits, spawning and large-scale agent simulation. Also use when the user mentions 'MassEntity', 'UMassProcessor', 'FMassEntityQuery', 'ForEachEntityChunk', 'FMassEntityManager', 'FMassFragment', 'FMassTag', 'FTransformFragment', 'UMassObserverProcessor', 'ObservedTypes', 'Defer', 'archetype', 'AMassSpawner', 'entity config asset', 'MassCrowd', 'ISM crowd', 'entity relations', or 'thousands of agents'. For State Tree behavior on entities, see ue-state-trees; for ZoneGraph and Smart Objects, see ue-ai-navigation; for thread-safety rules, see ue-async-threading.

Use this Skill: https://skilld.dev/gh/quodsoler/unreal-engine-skills/ue-mass-entity

This session only. Nothing lands on disk.

referencesmass-fragment-reference.md

≈2.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Mass Fragment Reference

Built-in element types, shared fragments and traits, with the header and Build.cs module each one needs in UE 5.8. Headers under Mass/ belong to the MassCore runtime module; the rest come from the MassGameplay, MassAI and MassCrowd plugins (all Experimental in 5.8).


Element base types

All declared in Mass/EntityElementTypes.h (module MassCore), all deriving from FMassElement. MassEntityTypes.h pulls them in transitively.

Base Kind Notes
FMassFragment Per-entity data Stored contiguously per chunk
FMassSparseFragment Per-entity data Lives outside the archetype; add/remove causes no entity move
FMassTag Marker Must declare no data members
FMassSparseTag Marker Add/remove without an archetype change
FMassChunkFragment Per-chunk data One instance per memory chunk
FMassSharedFragment Shared mutable One instance shared by referencing entities
FMassConstSharedFragment Shared immutable Configuration set at template build time
FMassRelation Relation type Derives from FMassTag; declared in MassEntityRelations.h (module MassEntity)

Per-entity fragments

Fragment Header Module Key fields
FTransformFragment Mass/EntityFragments.h MassCore FTransform Transform (protected)
FAgentRadiusFragment MassCommonFragments.h MassCommon float Radius = 40.f
FAgentHeightFragment MassCommonFragments.h MassCommon float Height = 180.f
FMassVelocityFragment MassMovementFragments.h MassMovement FVector Value
FMassForceFragment MassMovementFragments.h MassMovement FVector Value
FMassMoveTargetFragment MassNavigationFragments.h MassNavigation (MassAI) FVector Center, FVector Forward, float DistanceToGoal, float SlackRadius, FMassInt16Real DesiredSpeed, EMassMovementAction IntentAtGoal
FMassRepresentationFragment MassRepresentationFragments.h MassRepresentation EMassRepresentationType CurrentRepresentation, PrevRepresentation
FMassRepresentationLODFragment MassRepresentationFragments.h MassRepresentation TEnumAsByte<EMassLOD::Type> LOD, PrevLOD, EMassVisibility Visibility, float LODSignificance
FMassCrowdLaneTrackingFragment MassCrowdFragments.h MassCrowd FZoneGraphLaneHandle TrackedLaneHandle
FMassChildOfFragment Relations/MassChildOf.h MassEntity FMassEntityHandle Parent

FTransformFragment

Transform is protected. Use GetTransform() (const ref), GetMutableTransform() (mutable ref) and SetTransform(const FTransform&). A converting constructor from FTransform exists, which is what makes Builder.Add<FTransformFragment>(SpawnTransform) work.

This type moved into MassCore. MassCommonFragments.h only #includes it; MassCommon lists MassCore as a public dependency (MassCommon.Build.cs:19) so it resolves transitively, but include Mass/EntityFragments.h and add MassCore explicitly.

FMassVelocityFragment / FMassForceFragment

Both hold a single FVector Value. Forces are integrated into velocity, velocity into FTransformFragment, by the processors in Movement/MassMovementProcessors.h (UMassApplyMovementProcessor).

FMassMoveTargetFragment

DesiredSpeed is an FMassInt16Real, not a float. The action is private: read it with GetCurrentAction() / GetPreviousAction() and change it with CreateNewAction(EMassMovementAction, const UWorld&). EMassMovementAction (MassNavigationTypes.h) is Stand, Move, Animate.


Chunk fragments

A chunk fragment derives from FMassChunkFragment and holds one instance per memory chunk. Add it to a template with BuildContext.AddChunkFragment<T>(), bind it with Query.AddChunkRequirement<T>(Access, Presence), and read it with Context.GetChunkFragment<T>(). Chunk fragments are the only per-entity-adjacent data a SetChunkFilter predicate may read.

FMassRepresentationLODFragment is not a chunk fragment — it is a per-entity FMassFragment.


Shared and const shared fragments

Fragment Kind Header Module Key fields
FMassMovementParameters Const shared MassMovementFragments.h MassMovement float MaxSpeed = 200.f, float MaxAcceleration = 250.f, float DefaultDesiredSpeed = 140.f, float DefaultDesiredSpeedVariance = 0.1f
FMassRepresentationParameters Const shared MassRepresentationFragments.h MassRepresentation EMassRepresentationType LODRepresentation[EMassLOD::Max], float NotVisibleUpdateRate = 0.5f, uint8 bKeepLowResActors : 1
FMassStateTreeSharedFragment Const shared MassStateTreeFragments.h MassAIBehavior (MassAI) TObjectPtr<UStateTree> StateTree

FMassMovementParameters has no deceleration field; deceleration falls out of the force/velocity integration.

FMassRepresentationParameters::LODRepresentation maps each EMassLOD::Type slot to an EMassRepresentationType, which is how an entity is promoted to an actor up close and demoted back to an ISM instance at distance.

Bind shared data with Query.AddSharedRequirement<T>(Access, Presence) or Query.AddConstSharedRequirement<T>(Presence); read it with Context.GetMutableSharedFragment<T>() / Context.GetConstSharedFragment<T>(). Presence::Any is rejected for both.


Traits

Traits derive from UMassEntityTraitBase (MassEntityTraitBase.h, module MassSpawner) and implement BuildTemplate(FMassEntityTemplateBuildContext&, const UWorld&) const. Optional validation is ValidateTemplate(const FMassEntityTemplateBuildContext&, const UWorld&, FAdditionalTraitRequirements&) const — three parameters.

Trait Header Module Purpose
UMassAssortedFragmentsTrait MassAssortedFragmentsTrait.h MassSpawner Editor-authored Fragments and Tags arrays of FInstancedStruct
UMassMovableVisualizationTrait MassMovableVisualizationTrait.h MassRepresentation ISM/actor visualization for moving agents
UMassStationaryVisualizationTrait MassStationaryVisualizationTrait.h MassRepresentation Visualization for agents that never move
UMassDistanceVisualizationTrait MassDistanceVisualizationTrait.h MassRepresentation Distance-driven representation switching
UMassReplicationTrait MassReplicationTrait.h MassReplication Registers the entity with Mass replication
UMassStateTreeTrait MassStateTreeTrait.h MassAIBehavior (MassAI) Attaches a State Tree asset to the entity
UMassCrowdMemberTrait MassCrowdMemberTrait.h MassCrowd Adds FMassCrowdTag and lane tracking
UMassSmartObjectUserTrait MassSmartObjectUserTrait.h MassSmartObjects Lets the entity claim Smart Objects

UMassVisualizationTrait is soft-deprecated (its display name is "DEPRECATED Visualization"). It is still the base class of the movable and stationary traits and still owns the shared properties StaticMeshInstanceDesc (FStaticMeshInstanceVisualizationDesc), SkinnedMeshInstanceDesc, HighResTemplateActor, LowResTemplateActor, Params (FMassRepresentationParameters) and LODParams (FMassVisualizationLODParameters). Author new content against UMassMovableVisualizationTrait or UMassStationaryVisualizationTrait.

Assign traits to a UMassEntityConfigAsset (a UDataAsset in MassEntityConfigAsset.h); AMassSpawner lists config assets in EntityTypes and spawns Count entities.


Enums

EMassRepresentationType (MassRepresentationTypes.h, MassRepresentation)

Value Use
HighResSpawnedActor Full actor, closest entities
LowResSpawnedActor Cheap actor at medium range
SkinnedMeshInstance Instanced skinned mesh
StaticMeshInstance Instanced static mesh, the bulk of a crowd
None Not rendered

UE::Mass::Representation::IsValidMeshRepresentation() returns true for the two instanced-mesh values.

EMassLOD (MassLODTypes.h, MassLOD)

EMassLOD is a namespaced enum — namespace EMassLOD { enum Type : int { High, Medium, Low, Off, Max }; } — so it is stored as TEnumAsByte<EMassLOD::Type> and EMassLOD::Max doubles as the array size for LODRepresentation.

EMassVisibility (MassLODTypes.h, MassLOD)

CanBeSeen, CulledByFrustum, CulledByDistance, Max.

EMassObservedOperationFlags (MassEntityTypes.h, MassEntity)

None, AddElement, RemoveElement, CreateEntity, DestroyEntity, Add (= AddElement | CreateEntity), Remove (= RemoveElement | DestroyEntity), All.

EMassCommandOperationType (MassCommands.h, MassEntity)

Flush order is by bucket, not enum order (MassCommandBuffer.cpp:110-119): Create, Add, ChangeComposition, Set, then Remove and Destroy together; commands left as None run last.


Crowd types

Type Kind Header
FMassCrowdTag Tag MassCrowdFragments.h
FMassCrowdLaneTrackingFragment Fragment MassCrowdFragments.h
FMassCrowdObstacleFragment Fragment MassCrowdFragments.h
UMassCrowdSubsystem World subsystem MassCrowdSubsystem.h

UMassCrowdSubsystem derives from UMassSubsystemBase and tracks lane occupancy, density and waiting slots over a ZoneGraph. It specialises TMassExternalSubsystemTraits<UMassCrowdSubsystem> with GameThreadOnly = false and ThreadSafeWrite = false, so parallel processors may declare it through AddSubsystemRequirement.


Signals

UMassSignalSubsystem (MassSignalSubsystem.h, module MassSignals) wakes processors for specific entities instead of ticking every entity every frame. The signal name comes first:

SignalSubsystem->SignalEntity(FName("MyGame.Damaged"), Entity);
SignalSubsystem->DelaySignalEntity(FName("MyGame.Respawn"), Entity, 3.f);
SignalSubsystem->SignalEntityDeferred(Context, FName("MyGame.Damaged"), Entity);

Processors that react to signals derive from UMassSignalProcessorBase (MassSignalProcessorBase.h), which is also the base of UMassStateTreeProcessor.

Source: SKILL.md on GitHub

No alerts2d5 checks · Risk SAFE
  • Gen Agent Trust Hub2d

    The skill provides technical documentation and code templates for developing with the Unreal Engine Mass Entity system. No security vulnerabilities or malicious patterns were identified.

  • Socket2d

    No alerts

  • Snyk2d

    Risk: LOW · No issues

  • Runlayer6mo

    3 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f3742d7. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 3 days ago
metadata
{
  "version": "2.0.0",
  "engine": "5.8"
}

README badge

README badge for quodsoler/unreal-engine-skills/ue-mass-entity