Skip to content
smartargs
VantageDocumentation

Combat text reference

The default floating-text presenter, the style asset, the per-unit publisher, and the feed and interface for building your own presenter. For how to use it, see Combat text.

VtWorldSpaceCombatTextPresenter

Component. Add it with Add Component → Vantage → UI → VtWorldSpaceCombatTextPresenter.

Default combat-text presenter. Spawns TMP labels in world space above the target’s head, rises them by the style’s riseDistance over lifetimeSec, fades alpha linearly, and recycles them through a pool.

Inspector fields

Style

Field Type Default Range Description
Style (style) VtCombatTextStyle None Style asset mapping VtCombatTextKind → colour / prefix / duration. Leave empty to use a sensible built-in default (white damage, yellow crits, green heals, grey dodge).

Rendering

Field Type Default Range Description
Target Camera (targetCamera) Camera None Camera the text billboards toward. Leave empty to use Camera.main each frame.
Font (font) TMP_FontAsset None Font asset used by spawned TMP labels. Leave empty for TMP’s default.
Render On Top (renderOnTop) bool On When true, spawned labels render on top of all geometry — depth test is forced ZTest Always and the render queue is bumped to overlay. Use this for ARPG / RTS games where ‘+ 1234’ must always be visible regardless of the target’s mesh size or what’s between camera and target. Set false for MMO-style combat text that occludes behind walls / large bodies.
Horizontal Jitter (horizontalJitter) float 0.25 ≥ 0 Horizontal random jitter (units) applied at spawn so overlapping hits don’t stack on a single line.
Max Live Popups (maxLivePopups) int 64 ≥ 1 Upper bound on live popups. Older labels recycle early when this cap is hit — prevents UI swamp on heavy AoE.

Scripting API

Member Description
bool RenderOnTop { get; set; } Runtime toggle for the depth-test override. Takes effect on the next popup spawned — popups already in flight keep whatever material they were configured with. Recycled popups are re-assigned on every Show, so flipping this mid-session is safe.
static VtWorldSpaceCombatTextPresenter Instance { get; } First-found live presenter in the scene. Null before Awake or after the scene unloads. For advanced scenarios multiple presenters can coexist — this accessor simply returns the most recently-enabled one.
void Show(in VtCombatTextEvent evt, VtCombatTextStyle styleArg) Spawn a floating label for evt using styleArg, or this presenter’s style when it is null.

VtCombatTextAutoSubscriber

Component. Add it with Add Component → Vantage → UI → VtCombatTextAutoSubscriber. Adds VtUnitStats, VtUnit automatically.

Per-unit MonoBehaviour that translates VtUnitStats events into VtCombatTextEvents on VtCombatTextFeed.

Scripting API

Member Description
void EnsureSubscribed() Idempotent wire-up of the VtUnitStats event handlers. Safe to call repeatedly; the first successful call latches the subscription flag. Runs on its own when the component wakes up.

VtCombatTextStyle

Asset. Create it with Create → Vantage → UI → Combat Text Style.

ScriptableObject holding one Entry per VtCombatTextKind — colour, prefix, suffix, font scale, rise distance, lifetime, optional audio clip. Create one with Create → Vantage → UI → Combat Text Style, tune the entries and assign it to the presenter.

Inspector fields

Base

Field Type Default Range Description
Base Font Size (baseFontSize) float 6 ≥ 1 Default font size for all entries (multiplied by entry.fontScale).
Head Offset Y (headOffsetY) float 2 World-space vertical offset from the target’s transform.position. Adjust so text spawns near the unit’s head.

Entries

Field Type Default Range Description
Entries (entries) VtCombatTextStyle.Entry[] Empty Per-kind overrides. First matching entry for a kind wins.

Fallback

Field Type Default Range Description
Defaults (defaults) VtCombatTextStyle.Entry — Used when a kind has no matching entry.

Scripting API

Member Description
VtCombatTextStyle.Entry GetEntry(VtCombatTextKind kind) Look up the entry for kind. First match wins; no match returns defaults.
static VtCombatTextStyle CreateBuiltIn() Populate entries with a sensible built-in style (white damage, yellow crits, green heals, grey dodge / resist, blue absorb). Used by the default presenter when no style asset is assigned so it works out-of-the-box with zero authoring.

IVtCombatTextPresenter

Interface. Implemented by VtWorldSpaceCombatTextPresenter.

Rendering seam for combat-text events. Default implementation is VtWorldSpaceCombatTextPresenter (pooled TMP labels in world space). Swap for a custom presenter — UI-Toolkit overlay, particle-driven, screen-space toast — by disabling the default and subscribing your own implementation to VtCombatTextFeed.OnEvent.

Scripting API

Member Description
void Show(in VtCombatTextEvent evt, VtCombatTextStyle style) Render the given event. Implementations must not throw and must cope with style being the fallback default.

VtCombatTextEvent

Struct.

Payload pushed through VtCombatTextFeed whenever something happens on a unit that floating-text UI wants to surface. Struct — no allocation per hit.

Scripting API

Member Description
readonly VtCombatTextKind kind Which kind of event this is. Styles key off this.
readonly int amount Magnitude to display. For VtCombatTextKind.Damage / VtCombatTextKind.Heal / their crit/tick variants this is the final applied value. For VtCombatTextKind.Absorb this is the amount absorbed. Zero for VtCombatTextKind.Dodge / VtCombatTextKind.Immune / VtCombatTextKind.Resist (the style’s text label is what shows).
readonly VtDamageType damageType Element of the hit. Presenters can tint damage numbers per-element (fire = orange, cold = cyan) on top of the style’s base colour.
readonly bool isCrit True if the underlying hit crit. Already reflected in kind (Crit / CritHeal / DotTickCrit / HealTickCrit) but exposed as a separate flag so presenters that ignore kind can still detect crits quickly.
readonly VtUnitId attacker Attacker / healer. Resolve via VtUnitRegistry.Resolve if a live reference is needed. VtUnitId.None for environmental.
readonly VtUnit target The unit the text floats above. Presenters anchor the text’s world-space position to this transform.
readonly Vector3 worldPosition World-space spawn point. By default the target’s head position (target.transform.position + a small vertical offset) but publishers may override (e.g. impact point on the model).

VtCombatTextFeed

Static class.

Lightweight global pub/sub for VtCombatTextEvents. Damage / heal / evade sites call Publish; one or more presenters subscribe to OnEvent and render the text.

Scripting API

Member Description
static event Action<VtCombatTextEvent> OnEvent Fires whenever a combat-text-worthy event happens on any unit. Subscribers are responsible for filtering (e.g. by target faction, local-player focus) if they don’t want every unit’s chatter.
static void Publish(in VtCombatTextEvent evt) Publish an event. Safe to call with no subscribers — no-op. Called from inside damage / heal / evade paths; must be cheap (no allocations beyond the struct on the stack).
static void Clear() Remove every subscriber. Runs on its own when play mode starts.

VtCombatTextStyle.Entry

Serializable struct.

Per-kind visual configuration. Missing / null entries fall back to defaults.

Inspector fields

Field Type Default Range Description
Kind (kind) VtCombatTextKind Damage Which event kind this entry applies to.
Color (color) Color #00000000 Text colour. The label fades out from this colour over its lifetime.
Prefix (prefix) string Empty Text before the number (e.g. ‘+’ for heals, ‘DODGE’ for dodges). For Dodge / Immune / Resist the prefix usually IS the whole label and amount is 0.
Suffix (suffix) string Empty Text after the number (e.g. ‘!’ for crits).
Font Scale (fontScale) float 0 ≥ 0.1 Multiplier on the style’s base font size. Crits usually 1.5–2.0; ticks 0.75.
Rise Distance (riseDistance) float 0 ≥ 0 World-space upward drift over the text’s lifetime (units).
Lifetime Sec (lifetimeSec) float 0 ≥ 0.05 Seconds before the text fades out and is recycled.
Sound (sound) AudioClip None Optional SFX played when this kind fires. Audio source is the presenter’s own AudioSource (2D by default).

Enums

VtCombatTextKind

Classification of a floating-text event. Used by VtCombatTextStyle to look up per-kind visual settings (colour, prefix, font scale) and by VtCombatTextEvent as the payload’s tag.

Value Description
Damage Direct damage. Fires for any VtUnitStats.OnPostTakeDamage where appliedDamage > 0, !wasCrit, and not a tick.
Crit Critical direct damage — appliedDamage > 0 && wasCrit.
DotTick Damage-over-time tick landing (non-crit). DoT crits map to DotTickCrit.
DotTickCrit Critical DoT tick (tick + wasCrit).
Heal Non-crit heal applied via VtUnitStats.Heal.
CritHeal Critical heal.
HealTick Heal-over-time tick (non-crit).
HealTickCrit Critical heal-over-time tick.
Dodge Evaded (dodged) hit — VtUnitStats.OnEvaded.
Absorb Hit absorbed in full by a shield — pipeline reached the rounding step with appliedDamage == 0 but absorbed > 0.
Immune Pre-hook cancelled the hit (block / immunity / phase-out).
Resist Non-evaded, non-cancelled hit with appliedDamage == 0 — usually means element resistance + matrix reduced it to nothing.

VtDamageType

The element of an attack — routed through the corresponding resistX stat on VtCoreStats in VtUnitStats.TakeDamage.

Value Description
Physical Weapons, claws and falling rocks. Reduced by armor; resisted by stat.resist_physical.
Fire Fire and burning. Resisted by stat.resist_fire.
Cold Frost and ice. Resisted by stat.resist_cold.
Poison Poison and venom, often dealt over time. Resisted by stat.resist_poison.
True Bypasses all mitigation (resistance, armor, matrix). Use sparingly.
Lightning Electricity / chain-lightning / EMP-flavor. Resisted by stat.resist_lightning.
Holy Paladin / priest school. Strong vs undead in many genres. Resisted by stat.resist_holy.
Shadow Warlock / necromancer school — corruption, agony, void. Resisted by stat.resist_shadow. Often paired oppositionally with Holy.
Arcane Mage’s “raw magic” school — distinct from elemental. Magic missile, polymorph. Resisted by stat.resist_arcane. Conventionally hardest to resist.
Nature Druid / shaman school — earth, plant, weather, wildlife. Resisted by stat.resist_nature.