UMageItCombatTextRendererSlate
Base Class: UMageItCombatTextRendererBase
Interfaces: FTickableGameObject
Overview
Section titled “Overview”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.
Configuration Properties
Section titled “Configuration Properties”ZOrder(Integer,EditDefaultsOnly): Z-order the canvas is added to the viewport with. Default100.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. Default1.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, min1): 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.
Read-Only / Internal
Section titled “Read-Only / Internal”ActiveEvents(Array<FMageItCombatTextActiveSlateEvent>): Currently animating events. SeeFMageItCombatTextActiveSlateEvent.
Lifecycle Overrides
Section titled “Lifecycle Overrides”Initialize_Implementation
Section titled “Initialize_Implementation”Creates the SMageItCombatTextCanvas and adds it to GEngine->GameViewport (wrapped in an SWeakWidget) at
ZOrder.
RenderDamage_Implementation
Section titled “RenderDamage_Implementation”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.
Shutdown_Implementation
Section titled “Shutdown_Implementation”Removes the Slate canvas from the game viewport.
Overridable Functions (Blueprint Native Events)
Section titled “Overridable Functions (Blueprint Native Events)”-
GetVelocityDirection() -> Vector2DReturns a random drift direction/speed withinVelocityHalfConeAngleof straight up, betweenMinVelocityandMaxVelocity. -
ExtractCombatText(EventData) -> StringFormats the string to display. Defaults toDamageAmountrounded to the nearest integer. -
ExtractTextColor/ExtractShadowColor(EventData) -> LinearColorResolves the text/shadow color for a new event. Default toTextColor/ShadowColor. -
PrepareActiveEvent(ActiveEvent)Called once when an event is created. The default implementation rolls the drift direction, and copiesAnimationDuration,Gravity,TextColor, andShadowColorfrom the renderer’s defaults onto the event. -
ProcessDefaultAnimation(ActiveEvent, BaseScreenPos, DPIScale)Called every tick for every active event to compute itsCurrentScale,CurrentOpacity, andScreenPosition. The built-in implementation runs three phases over the event’s normalized lifetime (ElapsedTime / AnimationDuration):- Pop-in (
0%-10%): eases from0.5xto1.2xscale. - Pop-out / settle (
10%-20%): eases from1.2xback down to1.0x(TargetScale). - Float & fade (
20%-100%): eases opacity from1.0to0.0, while applyingDriftDirection(linear) andGravity(quadratic) displacement over elapsed time.
The final position is centered on the text’s pivot using
CachedTextSize, offset byPositionOffset, and divided by the viewport’s DPI scale. - Pop-in (
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.