UnitHealth

From Wowpedia
Jump to: navigation, search

Returns the current health of the specified unit.

local health = UnitHealth(unit);

Arguments

unit 
UnitId - identifies the unit to query health for

Returns

health 
Integer - current health of the specified unit, returns 0 if the specified unit does not exist (eg. "target" given but there is no target)

Example

Print the target's health to the chat frame:

DEFAULT_CHAT_FRAME:AddMessage( "target health ="..UnitHealth("target") )

See Also

Patch changes

Retail

Classic

  • WoW Icon update.png Patch 1.13.3 (2019-12-10): Changed to return real health values for NPCs in order to alleviate addon comms load from the Real Mob Health addon.
    Still returns health percentages when used on players. (Hotfix during build 33302, Feb 7 2020) [1]
  • WoW Icon update.png Patch 1.13.2 (2019-08-26): Versus 8.0.1, UnitHealth returns to older behaviour showing up to 100 for units outside your party or raid

References

  1. ^ Kaivax 2020-02-18. UI API Change for UnitHealth.