Skip to content

UMageItCombatTextRendererNiagara

Base Class: UMageItCombatTextRendererBase Interfaces: FTickableGameObject

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: SpriteMaterial samples 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 with FindSpriteIndex.


  • MasterSystemAsset (NiagaraSystem*, EditDefaultsOnly): The Niagara System spawned at Initialize. It must read the User.DamageInfo / User.DamageStyle arrays and User.SpawnCount / User.SpawnPulse variables this renderer writes every tick.
  • DefaultTextColor (LinearColor, EditDefaultsOnly): Forwarded to the system as User.DefaultTextColor.
  • OutlineColor (LinearColor, EditDefaultsOnly): Forwarded to the system as User.DefaultOutlineColor.
  • DigitSize (Float, EditDefaultsOnly): Forwarded as User.DigitSize. Default 40.0.
  • DigitSpacing (Float, EditDefaultsOnly): Horizontal offset between digits in a multi-digit number and the value forwarded as User.DigitSpacing. Default 30.0.
  • SpriteMaterial (UMaterialInterface*, EditDefaultsOnly): Forwarded as User.SpriteMaterial — the SDF atlas material sampled per-sprite.
  • ActiveNiagaraComponent (UNiagaraComponent*, BlueprintReadOnly): The single spawned Niagara component all events are batched into.
  • PendingEventsBatch (Array<FMageItCombatTextEvent>): Events accumulated since the last Tick flush.

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 whether ActiveNiagaraComponent is 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. Tick and RenderDamage both call it before doing anything else, so the system is transparently rebuilt after a level transition without needing to re-register this renderer.

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). SpawnPulseCounter is 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), where DigitOffset centers each digit horizontally around the number’s location using DigitSpacing.

Then sets User.SpawnCount (total digit count) and User.SpawnPulse (the running counter), and clears the batch.

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 of Abs(RoundToInt(DamageAmount)).
  • FindDamageStyle (EventData) -> Integer Passed through to Niagara as the Style component of User.DamageStyle. Defaults to 0 — override to vary style by damage type, critical hits, etc.
  • FindScale (EventData) -> Float Passed through to Niagara as the Scale component of User.DamageStyle. Defaults to 1.0.
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.