HealthComp:

The health component.

groupComponent Types

hp: number

Current health points. Setting it to a lower or higher value will trigger onHurt() and onHeal(). Setting it to a value greater than maxHP will set it to maxHP. Setting it to a value less than 0 will set it to 0 and trigger onDeath().

maxHP: number

Max amount of HP.

dead: boolean

Whether hp is 0.

onHurt(action: (deltaHP?: number)=>void): KEventController

Register an event that runs when the hp is lowered.

sincev2000.1

onHeal(action: (deltaHP?: number)=>void): KEventController

Register an event that runs when the hp is increased.

sincev2000.1

onDeath(action: ()=>void): KEventController

Register an event that runs when object's HP becomes zero.

sincev2000.1

kaplay logo

Misc

Layer