Skip to content
Website logo
YawLighthouse

Unreal Engine's Mass: Traits & Entity Templates

Author:
Nicholas Helish

Nicholas Helish

Game Developer

You already read the About Me  page! I’m Nicholas Helish, the author for this article, website, cool stuff, and fan of cats!

July 03, 2026 · 3 min read

A description of Traits & Entity Templates within Unreal Engine's Mass.

This blog post was written in reference to Unreal Engine 5.8

Overview

Traits(UMassEntityTraitBase) are UObject type’s, declared Abstract and EditInlineNew, that allow for designers to configure Entity Template’s and configure their default values within the editor. You can add not just Fragment configurations but also specific parameters to additionally configure the Trait for a better UX.

A Trait is not an asset on its own. Traits are Instanced subobjects held by an FMassEntityConfig, and the UDataAsset in this system is UMassEntityConfigAsset, which wraps that config. So the workflow is: author a Mass Entity Config asset, then add Trait instances inline to its Traits array. Config assets can also inherit from a Parent config, which is how Trait sets get shared rather than by referencing a Trait as an asset.

Traits are also where you can add default Tags and Fragments to an Entity while its Entity Template (FMassEntityTemplateData) is being built, by overriding ::BuildTemplate() on the Trait’s type. Every Trait writes into a shared FMassEntityTemplateBuildContext, and only once all of them have contributed does Mass hand the finished composition to FMassEntityManager::CreateArchetype() and store the resulting FMassArchetypeHandle on the finalized FMassEntityTemplate. So Traits configure the Template, and the Archetype is derived from it afterwards.

Example: Trait’s BuildTemplate
c++
void UMyTrait::BuildTemplate(FMassEntityTemplateBuildContext& BuildContext, const UWorld& World) const
{
    BuildContext.AddFragment<FTransformFragment>();

    BuildContext.AddTag<FMyTag>();
}
Note: Best Practice Suggestion

As a best practice, it may be good to add comment(s) for each Trait listing waht Fragments and Tags are added when ::BuildTemplate() executes, since a Trait can add multiple Fragments and Tags it helps avoid unknown behavior during design time.

As well as specifying what Fragments are needed for this Trait to function properly.

Example: Trait Comments

c++

/**
* Adding ==================
* Fragments:
* - FMyFragment
*
* Const Shared Fragments:
* - FMyConstSharedFragment
*
* Shared Fragments:
* - FMySharedFragment
*
* Tags:
* - FMyTag1
* - FMyTag2
*
* Requires ================
* Fragments:
* - FTransformFragment
*
* Tags:
* - FMyTag3
*/
UCLASS()
class UMyTrait : public UMassEntityTraitBase
{
    GENERATED_BODY()
public:

    // UMassEntityTraitBase overrides
    virtual void BuildTemplate(FMassEntityTemplateBuildContext& BuildContext, const UWorld& World) const override
    {
        FMassEntityManager& EntityManager = UE::Mass::Utils::GetEntityManagerChecked(World);
        
        BuildContext.AddConstSharedFragment(EntityManager.GetOrCreateConstSharedFragment(FMyConstSharedFragment()));

        BuildContext.AddSharedFragment(EntityManager.GetOrCreateSharedFragment(FMySharedFragment()));

        BuildContext.AddFragment<FMyFragment>();

        BuildContext.AddTag<FMyTag1>();
        BuildContext.AddTag<FMyTag2>();
    }
    // ~UMassEntityTraitBase overrides
};
Share this post

Other Mass Blog Posts