Next: Impact Damage, Previous: Explosion, Up: Combat [Contents][Index]
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.
float
hpHow much health do we start with?
Default value: 100.0f
float
maxHPHow much health can we have?
Default value: 100.0f
bool
autodestructDo we destroy the object when health runs out?
Default value: true
string
autoSaveKeySpecify 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: ""
GameObject
hitPrefabA prefab we spawn when we get hit. Perhaps a particle effect?
GameObject
hitPrefabSpawnPointA spawn point where you want the hit prefab to appear (perhaps near the center?)
AudioClip
hitSoundA sound you wish to play when we get hit
float
hitPauseTimeIf greater than 0, pause the game momentarily when we get hit. This adds a lot of weight to impacts!
Default value: 0
float
hitSoundVarianceHow much do you want to vary the pitch of the hit sound?
Default value: .1f
GameObject[]
deathPrefabsWhat should we spawn when we die from HP loss?
Slider
uIHealthBarIf 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.
GameObject
hitTextPrefabA 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.
GameObject
hitTextSpawnPointA spawn point where you want the hit text to appear (perhaps above the object?)
GUISkin
guiSkinWhat skin should we use for the Legacy GUI
bool
showHealthBarGUIShould we show a legacy Unity GUI? NOTE: Not suitable for mobile devices.
Default value: false
Rect
healthBarNormalized viewport rectangle describing the area of the health bar, values between 0 and 1
Default value: new Rect(.2f, .01f, .4f, .085f)
bool
autoHideShould we hide the health bar when health is full?
Default value: false
Color
barColorShould we color this bar to differentiate it from others?
Default value: Color.white
MessageManager.ManagedMessage
healthGoneMessageWhen we run out of health, what message should we send?
MessageManager.ManagedMessage
hitMessageWhen we are hit, what message should we send?
Stuns MultiGame AI and CharacterOmnicontroller components attached to this object
Argument: How long should the stun last in seconds?
Kill this object immediately! Works even if the object is invulnerable
Change the health this object has
Argument: Amount to change the health by. Positive to increase, negative to decrease.
Change the maximum health this object can have
Argument: Amount to change the max health by. Positive to increase, negative to decrease.
Disables invulnerability on this object, allowing it do die if hp is less than or equal to 0
Prevents this object from dying even if it’s health goes below 0. It can still be killed with the ’Die’ message
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?
float
hpHow much health do we start with?
Default value: 100.0f
float
maxHPHow much health can we have?
Default value: 100.0f
bool
autodestructDo we destroy the object when health runs out?
Default value: true
string
autoSaveKeySpecify 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: ""
GameObject
hitPrefabA prefab we spawn when we get hit. Perhaps a particle effect?
GameObject
hitPrefabSpawnPointA spawn point where you want the hit prefab to appear (perhaps near the center?)
AudioClip
hitSoundA sound you wish to play when we get hit
float
hitPauseTimeIf greater than 0, pause the game momentarily when we get hit. This adds a lot of weight to impacts!
Default value: 0
float
hitSoundVarianceHow much do you want to vary the pitch of the hit sound?
Default value: .1f
GameObject[]
deathPrefabsWhat should we spawn when we die from HP loss?
Slider
uIHealthBarIf 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.
GameObject
hitTextPrefabA 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.
GameObject
hitTextSpawnPointA spawn point where you want the hit text to appear (perhaps above the object?)
GUISkin
guiSkinWhat skin should we use for the Legacy GUI
bool
showHealthBarGUIShould we show a legacy Unity GUI? NOTE: Not suitable for mobile devices.
Default value: false
Rect
healthBarNormalized viewport rectangle describing the area of the health bar, values between 0 and 1
Default value: new Rect(.2f, .01f, .4f, .085f)
bool
autoHideShould we hide the health bar when health is full?
Default value: false
Color
barColorShould we color this bar to differentiate it from others?
Default value: Color.white
MessageManager.ManagedMessage
healthGoneMessageWhen we run out of health, what message should we send?
MessageManager.ManagedMessage
hitMessageWhen we are hit, what message should we send?
Stuns MultiGame AI and CharacterOmnicontroller components attached to this object
Argument: How long should the stun last in seconds?
Kill this object immediately! Works even if the object is invulnerable
Change the health this object has
Argument: Amount to change the health by. Positive to increase, negative to decrease.
Change the maximum health this object can have
Argument: Amount to change the max health by. Positive to increase, negative to decrease.
Disables invulnerability on this object, allowing it do die if hp is less than or equal to 0
Prevents this object from dying even if it’s health goes below 0. It can still be killed with the ’Die’ message
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: Impact Damage, Previous: Explosion, Up: Combat [Contents][Index]