Health Node
A custom Godot node designed to store and update the health amount of a node, emitting signals based on health amount changes and set properties.
Last updated
A custom Godot node designed to store and update the health amount of a node, emitting signals based on health amount changes and set properties.
Last updated
The node enables the addition of health capabilities, which can be adjusted by invoking the health update_amount
function. It can automatically send signals based on changes in the health amount and set properties.
Customizable health and maximum health values.
Simplified connection to a TextureProgressBar
and ProgressBar
node as a health bar.
Configurable auto-hide feature for the health bar.
Option to switch from manual to automatic health update behavior.
Ability to pause the automatic health update for a specified number of seconds.
Ability to enable or disable damageable, healable, and revivable behaviors.
Signals are emitted based on behavior, set properties, and updates to health amounts.
"I searched the Asset Library for a health component but found only limited options. Since health is a crucial component in almost every game, as most games utilize some form of health mechanism for their characters, I decided to create my own. I didn't expect it to become this versatile."
After enabling this plugin, you can add the Health
node as a child of another node, usually a CharacterBody
or StaticBody
, to use its capabilities.
Right-click on a node or press Ctrl+A.
Type "health" on the Search textbox of the Create New Node form to filter the node list and easily find the Health
node.
Double-click the Health
node to add as a child of the node.
Amount: The current amount of health.
Max Amount: The maximum amount of health.
Texture Progress: The visual representation of the health status using TextureProgressBar
node.
Progress: The visual representation of the health status using ProgressBar
node.
Hide in Seconds: The number of seconds until the health bar is hidden from view. If the value is set to 0, the health bar will remain visible at all times.
Behavior: The behavior of the health node
Default: Manual control.
Auto Increase: Automatically increase health by Change Percent.
Auto Decrease: Automatically decrease health by Change Percent.
Change Percent: The percentage of automatic change, calculated based on the Max Amount. If Behavior is set to Default
, no changes will occur, even if the percentage is greater than 0.
Change in Seconds: The number of seconds until an automatic health change occurs. The automatic health change is controlled by a change timer in the health node.
Pause in Seconds: The number of seconds to pause the automatic health change. The pause in automatic health change is controlled by a pause timer in the health node.
Damageable: Enable this if health can be decreased.
Healable: Enable this if health can be increased.
Revivable: Enable this if health can be increased when the amount is already at or below 0.
Emit Damage: Enable this to emit the damage
signal.
Emit Death: Enable this to emit the death
signal.
Emit Heal: Enable this to emit the heal
signal.
Emit Revive: Enable this to emit the revive
signal.
get_class() -> String
Returns the object's class name, as a String. This function overrides the base Object's built-in function Object.get_class.
is_behavior_paused() -> bool
A function to check if the automatic health change is paused.
pause_behavior()
A function to pause the automatic health change for a specified number of seconds using the Pause in seconds value.
Changing the behavior to default will not stop the pause timer. However, if the behavior is restarted while the pause timer is active, it will likely delay the start of the change timer until the pause timer expires.
sync_healthbar()
A function to synchronize the health bar with the current health values.
update_amount(_amount: float)
A function that updates the health amount and emits signals based on the amount. The _amount
parameter is the value added to the current health Amount.
update(body: Node, amount: float, health: float)
This signal is emitted when the health is updated. The parameter body refers to the parent of this node, the parameter amount is the value added to the health, and the parameter health is the new health value after adding amount.
If parameter amount is negative, the damage signal will be emitted if Damageable and Emit Damage is enabled; if it is positive, the heal signal will be emitted if Healable and Emit Heal is enabled.
If the GlobalHealth singleton is enabled, this signal is emitted on a global scale.
damage(damage: float, health: float)
This signal is emitted when the health is updated with a negative amount.
This is emitted only if Damageable and Emit Damage are enabled.
heal(recovery: float, health: float)
This signal is emitted when the health is updated with a positive amount.
This is emitted only if Healable and Emit Heal are enabled.
death()
This signal is emitted when the health reaches or falls below 0.
This is emitted only if Damageable and Emit Death are enabled.
revive(amount: float, health: float)
This signal is emitted when the health is updated with a positive parameter amount while the current health value is 0 or negative.
This is emitted only if Revivable and Emit Revive are enabled.
The GlobalHealth
singleton facilitates global relay of the update signal.