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”Calls the internal EnsureSystem(), which 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.
Note: The Niagara component lives in the world, not on the renderer, so it doesn’t survive level travel.
EnsureSystem()checks whetherActiveNiagaraComponentis still valid and still belongs to the current world, and only respawns (and re-applies the user parameters, and re-arms the warmup flag) when it isn’t.TickandRenderDamageboth call it before doing anything else, so the system is transparently rebuilt after a level transition without needing to re-register this renderer.
RenderDamage_Implementation
Section titled “RenderDamage_Implementation”virtual void RenderDamage_Implementation(const FMageItCombatTextEvent& EventData) override;Calls EnsureSystem() and, only if it succeeds, appends EventData to PendingEventsBatch — an event that arrives
with no valid world or no MasterSystemAsset assigned is dropped rather than queued, since nothing would ever drain
it. All actual work is deferred to Tick so multiple events landing in the same frame are flushed together.
Returns immediately if the batch is empty or EnsureSystem() fails (no world, no asset). Otherwise, once 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 DestroyComponent() on ActiveNiagaraComponent (if still valid), clears the pointer, and empties
PendingEventsBatch, before calling the parent implementation (which marks the renderer as shut down — see
UMageItCombatTextRendererBase).
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.