Skip to content

Scripts.Health

Wesley Haws edited this page Jan 1, 2017 · 3 revisions

##Scripts - Health

###What does this do?


This is to keep track if the player is alive or not. If the health <= 0 then the player enters the death state. Will display visuals on damage and trigger animation events on damage. Will also play sounds when gaining and losing health.

###Who/What is this for?


This is designed to work with the GUI health bar to see if the player is still alive or needs to be taken to the death screen.

####Setup


Example Setup:

Example Setup

Parameter Type Description
Anim Animator List A list of animators to update states on. All must contain the same parameter.
Health int Hit points for your character.
Regeneration int Hit points per second to regain if not taking damage.
Gui On Hit Texture2D A GUI visual to display when health is lost.
Gui Fade Speed int How fast the GUI visual will fade out after appearing.
Hit Sounds Volume float Override volume level to play sounds at.
Player Camera Camera The camera to display a visual on.
Hit Sounds AudioClip List List to randomly select and play a sound from when health is lost.
Gain Health Sounds AudioClip List List to randomly select and play a sound from when health is gained.
Audio Source AudioSource Where to play all of these sounds from.
Death Cam Parent Transform Where to make the camera a child to when health is <= 0.
Debug Health bool For debugging only. Logs health
Debug Dir Hit bool For debugging only. Logs the direction from where the player was hit.
Stagger On Every Hit bool Whether or not to play a damaged animation when health is lost. (Requires All animators to have the same parameter)
Death Position GameObject Legacy. Where to spawn a ragdolled player. (No Longer in use.)

Clone this wiki locally