UMageItCombatTextRendererNiagara
Base Class: UMageItCombatTextRendererBase
Interfaces: FTickableGameObject
Overview
Section titled “Overview”UMageItCombatTextRendererNiagara renders combat text as GPU-driven SDF sprites through a single shared Niagara
system. Instead of processing events one at a time, it batches them: every RenderDamage call just appends to
PendingEventsBatch, and the whole batch is flushed into the Niagara system’s user parameter arrays once per
Tick. This keeps the number of expensive array-update calls constant regardless of how many hits land in a frame,
making it the renderer of choice when hundreds of numbers can appear on screen at once.
Each digit of a number is spawned as its own particle, offset horizontally from the number’s center by
DigitSpacing, so multi-digit numbers line up correctly.
Tip:
SpriteMaterialsamples a signed distance field texture atlas — see Generating the SDF Atlas for how to build one with msdf-atlas-gen and keep its glyph order in sync withFindSpriteIndex.
Configuration Properties
Section titled “Configuration Properties”MasterSystemAsset(NiagaraSystem*,EditDefaultsOnly): The Niagara System spawned atInitialize. It must read theUser.DamageInfo/User.DamageStylearrays andUser.SpawnCount/User.SpawnPulsevariables this renderer writes every tick.DefaultTextColor(LinearColor,EditDefaultsOnly): Forwarded to the system asUser.DefaultTextColor.OutlineColor(LinearColor,EditDefaultsOnly): Forwarded to the system asUser.DefaultOutlineColor.DigitSize(Float,EditDefaultsOnly): Forwarded asUser.DigitSize. Default40.0.DigitSpacing(Float,EditDefaultsOnly): Horizontal offset between digits in a multi-digit number and the value forwarded asUser.DigitSpacing. Default30.0.SpriteMaterial(UMaterialInterface*,EditDefaultsOnly): Forwarded asUser.SpriteMaterial— the SDF atlas material sampled per-sprite.
Read-Only / Internal
Section titled “Read-Only / Internal”ActiveNiagaraComponent(UNiagaraComponent*,BlueprintReadOnly): The single spawned Niagara component all events are batched into.PendingEventsBatch(Array<FMageItCombatTextEvent>): Events accumulated since the lastTickflush.
Lifecycle Overrides
Section titled “Lifecycle Overrides”Initialize_Implementation
Section titled “Initialize_Implementation”Spawns MasterSystemAsset via UNiagaraFunctionLibrary::SpawnSystemAtLocation at the world origin (each event
carries its own world position through User.DamageInfo, so the component itself doesn’t need to move), and sets
the color/size/material user parameters listed above. Sets an internal warmup flag so the first Tick after
creation is skipped, giving the Niagara component a frame to finish initializing before arrays are pushed to it.
RenderDamage_Implementation
Section titled “RenderDamage_Implementation”virtual void RenderDamage_Implementation(const FMageItCombatTextEvent& EventData) override;Simply appends EventData to PendingEventsBatch. All actual work is deferred to Tick so multiple events landing
in the same frame are flushed together.
If the batch is non-empty and the warmup frame has passed, builds two arrays from PendingEventsBatch:
User.DamageStyle(Array<Vector4>): one entry per digit —(Style, Scale, SpriteIndex, SpawnPulseCounter).SpawnPulseCounteris a monotonically increasing per-digit counter used by the Niagara system as a random seed.User.DamageInfo(Array<Vector4>): one entry per digit —(Location.X, Location.Y, Location.Z, DigitOffset), whereDigitOffsetcenters each digit horizontally around the number’s location usingDigitSpacing.
Then sets User.SpawnCount (total digit count) and User.SpawnPulse (the running counter), and clears the batch.
Shutdown_Implementation
Section titled “Shutdown_Implementation”Calls DestroyInstance() on ActiveNiagaraComponent.
Overridable Functions (Blueprint Native Events)
Section titled “Overridable Functions (Blueprint Native Events)”FindSpriteIndex(EventData) -> Array<Integer>Determines which sprite index in the SDF atlas represents each character of the displayed number. The default implementation returns one index per base-10 digit ofAbs(RoundToInt(DamageAmount)).FindDamageStyle(EventData) -> IntegerPassed through to Niagara as theStylecomponent ofUser.DamageStyle. Defaults to0— override to vary style by damage type, critical hits, etc.FindScale(EventData) -> FloatPassed through to Niagara as theScalecomponent ofUser.DamageStyle. Defaults to1.0.
Static Utilities
Section titled “Static Utilities”ConvertStringToAlphabetIndices
Section titled “ConvertStringToAlphabetIndices”static TArray<int32> ConvertStringToAlphabetIndices(const FString& InputString, const int32 StartIndex = 0);(Blueprint Pure) Lowercases InputString and maps each letter a-z to a sequential index starting at
StartIndex, skipping non-letter characters. Intended for use inside a custom FindSpriteIndex override, so words
like “MISS” or “BLOCK” can be rendered from the same SDF atlas as digits, provided the atlas lays out the alphabet
starting at StartIndex.