Next: , Previous: , Up: Combat   [Contents][Index]


6.6 Health

Component: Health

This flexible Health implementation is fully compatible with all MultiGame systems and forms the basis for combat and death in your game worlds. It receives the ’ModifyHealth’ message with a floating point value. Positive numbers heal it, negative numbers damage it. Make anything killable! Fill out message senders above to send messages to other MultiGame components.

Basic Settings

Field of Health: float hp

How much health do we start with?

Default value: 100.0f

Field of Health: float maxHP

How much health can we have?

Default value: 100.0f

Destruction Settings

Field of Health: bool autodestruct

Do we destroy the object when health runs out?

Default value: true

Optional Field of Health: string autoSaveKey

Specify a key to save the health in Player Prefs. Will load when any instance of this object is instantiated. If you don’t want to save, just leave this blank.

Default value: ""

Game Feel

Field of Health: GameObject hitPrefab

A prefab we spawn when we get hit. Perhaps a particle effect?

Field of Health: GameObject hitPrefabSpawnPoint

A spawn point where you want the hit prefab to appear (perhaps near the center?)

Field of Health: AudioClip hitSound

A sound you wish to play when we get hit

Field of Health: float hitPauseTime

If greater than 0, pause the game momentarily when we get hit. This adds a lot of weight to impacts!

Default value: 0

Field of Health: float hitSoundVariance

How much do you want to vary the pitch of the hit sound?

Default value: .1f

Field of Health: GameObject[] deathPrefabs

What should we spawn when we die from HP loss?

GUI Settings

Field of Health: Slider uIHealthBar

If using the Unity UI, create a slider for the health and drop a reference to it here. The slider value show the health amount. This can be used to create either a health bar near the object in the scene, or displayed as a HUD. See the Unity GUI documentation/tutorials for more information. You can disable or reskin the handle so that it doesn’t look draggable.

Field of Health: GameObject hitTextPrefab

A prefab with a Text component in it’s heirarchy which will be used to display damage values. We recommend adding a Billboard component as well to ensure that it always faces the camera.

Field of Health: GameObject hitTextSpawnPoint

A spawn point where you want the hit text to appear (perhaps above the object?)

Immediate Mode GUI settings

Optional Field of Health: GUISkin guiSkin

What skin should we use for the Legacy GUI

Field of Health: bool showHealthBarGUI

Should we show a legacy Unity GUI? NOTE: Not suitable for mobile devices.

Default value: false

Field of Health: Rect healthBar

Normalized viewport rectangle describing the area of the health bar, values between 0 and 1

Default value: new Rect(.2f, .01f, .4f, .085f)

Field of Health: bool autoHide

Should we hide the health bar when health is full?

Default value: false

Field of Health: Color barColor

Should we color this bar to differentiate it from others?

Default value: Color.white

Message Senders

Field of Health: MessageManager.ManagedMessage healthGoneMessage

When we run out of health, what message should we send?

Field of Health: MessageManager.ManagedMessage hitMessage

When we are hit, what message should we send?

Available Messages

Message on Health: HitStun (float)

Stuns MultiGame AI and CharacterOmnicontroller components attached to this object

Argument: How long should the stun last in seconds?

Message on Health: Die ()

Kill this object immediately! Works even if the object is invulnerable

Message on Health: ModifyHealth (float)

Change the health this object has

Argument: Amount to change the health by. Positive to increase, negative to decrease.

Message on Health: ModifyMaxHealth (float)

Change the maximum health this object can have

Argument: Amount to change the max health by. Positive to increase, negative to decrease.

Message on Health: MakeVulnerable ()

Disables invulnerability on this object, allowing it do die if hp is less than or equal to 0

Message on Health: MakeInvulnerable ()

Prevents this object from dying even if it’s health goes below 0. It can still be killed with the ’Die’ message

Message on Health: TempInvulnerability (float)

Prevents this object from dying even if it’s health goes below 0 for a limited duration. It can still be killed with the ’Die’ message

Argument: How long (in seconds) should the object be invulnerable?

Basic Settings

Field of Health: float hp

How much health do we start with?

Default value: 100.0f

Field of Health: float maxHP

How much health can we have?

Default value: 100.0f

Destruction Settings

Field of Health: bool autodestruct

Do we destroy the object when health runs out?

Default value: true

Optional Field of Health: string autoSaveKey

Specify a key to save the health in Player Prefs. Will load when any instance of this object is instantiated. If you don’t want to save, just leave this blank.

Default value: ""

Game Feel

Field of Health: GameObject hitPrefab

A prefab we spawn when we get hit. Perhaps a particle effect?

Field of Health: GameObject hitPrefabSpawnPoint

A spawn point where you want the hit prefab to appear (perhaps near the center?)

Field of Health: AudioClip hitSound

A sound you wish to play when we get hit

Field of Health: float hitPauseTime

If greater than 0, pause the game momentarily when we get hit. This adds a lot of weight to impacts!

Default value: 0

Field of Health: float hitSoundVariance

How much do you want to vary the pitch of the hit sound?

Default value: .1f

Field of Health: GameObject[] deathPrefabs

What should we spawn when we die from HP loss?

GUI Settings

Field of Health: Slider uIHealthBar

If using the Unity UI, create a slider for the health and drop a reference to it here. The slider value show the health amount. This can be used to create either a health bar near the object in the scene, or displayed as a HUD. See the Unity GUI documentation/tutorials for more information. You can disable or reskin the handle so that it doesn’t look draggable.

Field of Health: GameObject hitTextPrefab

A prefab with a Text component in it’s heirarchy which will be used to display damage values. We recommend adding a Billboard component as well to ensure that it always faces the camera.

Field of Health: GameObject hitTextSpawnPoint

A spawn point where you want the hit text to appear (perhaps above the object?)

Immediate Mode GUI settings

Optional Field of Health: GUISkin guiSkin

What skin should we use for the Legacy GUI

Field of Health: bool showHealthBarGUI

Should we show a legacy Unity GUI? NOTE: Not suitable for mobile devices.

Default value: false

Field of Health: Rect healthBar

Normalized viewport rectangle describing the area of the health bar, values between 0 and 1

Default value: new Rect(.2f, .01f, .4f, .085f)

Field of Health: bool autoHide

Should we hide the health bar when health is full?

Default value: false

Field of Health: Color barColor

Should we color this bar to differentiate it from others?

Default value: Color.white

Message Senders

Field of Health: MessageManager.ManagedMessage healthGoneMessage

When we run out of health, what message should we send?

Field of Health: MessageManager.ManagedMessage hitMessage

When we are hit, what message should we send?

Available Messages

Message on Health: HitStun (float)

Stuns MultiGame AI and CharacterOmnicontroller components attached to this object

Argument: How long should the stun last in seconds?

Message on Health: Die ()

Kill this object immediately! Works even if the object is invulnerable

Message on Health: ModifyHealth (float)

Change the health this object has

Argument: Amount to change the health by. Positive to increase, negative to decrease.

Message on Health: ModifyMaxHealth (float)

Change the maximum health this object can have

Argument: Amount to change the max health by. Positive to increase, negative to decrease.

Message on Health: MakeVulnerable ()

Disables invulnerability on this object, allowing it do die if hp is less than or equal to 0

Message on Health: MakeInvulnerable ()

Prevents this object from dying even if it’s health goes below 0. It can still be killed with the ’Die’ message

Message on Health: TempInvulnerability (float)

Prevents this object from dying even if it’s health goes below 0 for a limited duration. It can still be killed with the ’Die’ message

Argument: How long (in seconds) should the object be invulnerable?


Next: , Previous: , Up: Combat   [Contents][Index]