Skip to content

UMageItCombatTextRendererSlate

Base Class: UMageItCombatTextRendererBase Interfaces: FTickableGameObject

UMageItCombatTextRendererSlate renders combat text without allocating any UUserWidget. A single SMageItCombatTextCanvas (an SLeafWidget) is added directly to the game viewport at Initialize, and every active event is a lightweight FMageItCombatTextActiveSlateEvent struct animated in Tick and drawn in the canvas’s OnPaint. This makes it the cheapest renderer per concurrent number, at the cost of the visuals being driven by code (ProcessDefaultAnimation) rather than a designer-authored widget.

It ships with a built-in three-phase animation: pop-in, pop-out (settle), and float-up-and-fade.


  • ZOrder (Integer, EditDefaultsOnly): Z-order the canvas is added to the viewport with. Default 100.
  • DefaultGravity (Vector2D, EditDefaultsOnly, BlueprintReadOnly): Constant screen-space acceleration applied over an event’s lifetime.
  • PositionOffset (Vector2D, EditDefaultsOnly, BlueprintReadOnly): Constant pixel offset applied to every event’s final screen position.
  • DefaultAnimationDuration (Float, EditDefaultsOnly, BlueprintReadOnly): Total lifetime of the built-in animation, in seconds. Default 1.0.
  • VelocityHalfConeAngle (Float, EditDefaultsOnly, BlueprintReadOnly, 0-180): Half-angle (in degrees) of the random cone around straight up that each event’s drift direction is chosen from.
  • MinVelocity / MaxVelocity (Float, EditDefaultsOnly, BlueprintReadOnly): Range the random drift speed is chosen from.
  • TextFont (SlateFontInfo, EditDefaultsOnly): Font used to draw and measure combat text.
  • TextColor / ShadowColor (LinearColor, EditDefaultsOnly): Default text and shadow colors.
  • bRenderShadow (Boolean, EditDefaultsOnly): Whether the drop shadow pass is drawn.
  • ShadowOffset (Vector2D, EditDefaultsOnly): Pixel offset of the drop shadow from the main text.
  • bSimulateShadowBlur (Boolean, EditDefaultsOnly): Whether the shadow is softened using multi-pass jittered offsets instead of a single hard-edged copy.
  • BlurRadius (Float, EditDefaultsOnly): Jitter distance used to simulate shadow blur.
  • LayersPerTick (Integer, EditDefaultsOnly, min 1): Draw layers distributed across all active events per paint pass. Each layer costs an extra draw call — raise it if fast-moving overlapping numbers need finer paint ordering.

Creates the SMageItCombatTextCanvas and adds it to GEngine->GameViewport (wrapped in an SWeakWidget) at ZOrder.

Extracts the display string via ExtractCombatText, measures it with FSlateFontMeasure (caching the result per unique string in TextSizeCache, since damage numbers repeat heavily and text measurement is one of the pricier Slate calls — safe as long as TextFont doesn’t change after Initialize), builds a new FMageItCombatTextActiveSlateEvent, runs PrepareActiveEvent on it, and appends it to ActiveEvents.

For each active event (iterated in reverse for safe removal): advances ElapsedTime; if it has exceeded AnimationDuration, leaves it for removal; otherwise projects Payload.Location to screen space. If the location is behind the camera, sets CurrentOpacity to 0 and skips further processing; otherwise calls ProcessDefaultAnimation. After the loop, removes every event whose ElapsedTime >= AnimationDuration.

Removes the Slate canvas from the game viewport.


Overridable Functions (Blueprint Native Events)

Section titled “Overridable Functions (Blueprint Native Events)”
  • GetVelocityDirection () -> Vector2D Returns a random drift direction/speed within VelocityHalfConeAngle of straight up, between MinVelocity and MaxVelocity.

  • ExtractCombatText (EventData) -> String Formats the string to display. Defaults to DamageAmount rounded to the nearest integer.

  • ExtractTextColor / ExtractShadowColor (EventData) -> LinearColor Resolves the text/shadow color for a new event. Default to TextColor / ShadowColor.

  • PrepareActiveEvent (ActiveEvent) Called once when an event is created. The default implementation rolls the drift direction, and copies AnimationDuration, Gravity, TextColor, and ShadowColor from the renderer’s defaults onto the event.

  • ProcessDefaultAnimation (ActiveEvent, BaseScreenPos, DPIScale) Called every tick for every active event to compute its CurrentScale, CurrentOpacity, and ScreenPosition. The built-in implementation runs three phases over the event’s normalized lifetime (ElapsedTime / AnimationDuration):

    1. Pop-in (0%-10%): eases from 0.5x to 1.2x scale.
    2. Pop-out / settle (10%-20%): eases from 1.2x back down to 1.0x (TargetScale).
    3. Float & fade (20%-100%): eases opacity from 1.0 to 0.0, while applying DriftDirection (linear) and Gravity (quadratic) displacement over elapsed time.

    The final position is centered on the text’s pivot using CachedTextSize, offset by PositionOffset, and divided by the viewport’s DPI scale.


Paint Pass (SMageItCombatTextCanvas::OnPaint)

Section titled “Paint Pass (SMageItCombatTextCanvas::OnPaint)”

For every active event with CurrentOpacity > 0, draws a soft drop shadow as six jittered copies (BlurRadius offset in each direction) at 25% of the text’s alpha, one Slate layer below the main text draw. Distributes LayersPerTick across the active event count so that, once accumulated share crosses 1.0, subsequent events move to the next draw layer — this trades extra draw calls for finer paint-order control among fast-moving, overlapping numbers.