Taking Damage / Healing
Last updated
Last updated
It is important that your character has a health bar and receives damage, for this you can add the JU Health script to your character
The Damage Trigger is a simple script to give damage to a character, you need to use it together with a collider with the parameter "Is Trigger" turned on, you can adjust the damage and choose the tag of which character you want to take damage.
if you leave "Character Tag" empty, the Damage Trigger will damage any character that has JU Health.
The JU Damager is a more complex option for dealing damage to a character, you can use it as a trigger, normal collider with a rigidbody, or as a raycast.
It supports Particles and Audio effect, it is the same component used in Malee weapons and HitBoxes
To deal damage to a character that has a JU Character is very simple, just call the JUHealth.DoDamage(5);
method.
See the example below:
This script is designed to be attached to a GameObject in Unity with a collider wich the parameter "Is Trigger" turned on. When another GameObject enters in trigger, it tries to find a JUHealth component on that GameObject and applies damage to it using the value stored in the Damage
field.
Healing a character is as easy as taking damage.
A Health Power Up Prefab is already included by default that adds some health points to the player:
To heal a character just add Health Points(HP) to the Health variable, for example:
JUHealth
.Health += 10;
<- That line of code will add 10 health points when called
See this example below
The script above is a simple health regeneration system, it will add HP over time.