JU TPS Documentation
  • 🤩Welcome to JU TPS
  • 😄Quick Start
    • How to start a new scene
    • How to create a JU Character / Reskin Default Character / Setup New Characters
      • Ragdoll
      • Damageable Body
      • Physical Damage
      • Body Leaning Setup
      • Taking Damage / Healing
      • Footstep System
      • Resizable Capsule Collider
    • 📦 Addon Installer
  • 🎮Game Development
    • Game Styles
      • Third Person Shooter Style
      • First Person Shooter Style
      • Top Down Style
      • 2.5D Sidescroller Style
      • ⚠️Important Info About Cross-Plataform
    • Controls / Inputs
      • JU Input Manager
      • Input Events
    • How to create a Mobile Game with JU TPS
      • Mobile Inputs
    • How to load scene
      • Scene Controller
    • How to use Cover System
    • How to use inventory and add items
      • Inventory in UI
      • How to switch between items
      • How to align weapon rotation
    • How to create weapons and items
      • Prevent gun clipping through walls
      • Creating Projectiles/Bullets
    • How to use Dual Wielding System
    • How to use Armor/Cloth System
    • How to use Vehicle System
      • Standard Vehicle Configuration
      • How to create a Car Controller
      • How to create a Motorcycle Controller
      • Vehicle Engine Sounds
      • Coding Custom Wheeled Vehicles
      • How to enter and exit from a vehicle
    • How to use Gravity Switching
    • How to use Actions/Skill and Animation Events
      • JU TPS State Machine Behaviours
      • JUTPSActions Lib Scripting Reference
    • Camera State Trigger
    • How to use Enemies AI
    • How to use Vehicles AI
  • ⚙️Tools, Utils and Tutorials
    • General Tutorials
      • How to do Ragdoll Fall with Input Event
      • How to disable FPS Aim Mode / Scope / Iron Sight Aim
    • Auto Scripts
    • Icon Generator Tool
    • Destructible Objects System
      • Fracture Generator Tool
    • Pixel Quality Scaler
    • Camera Shake
    • Slow Motion
    • Gizmo Drawer
  • ▶️Video Tutorials
    • How to use JU TPS
  • 💬Discord Community
  • ❓Support | Help
  • 📍Roadmap
  • 🔃Change Log
  • 📦Official Addons
Powered by GitBook
On this page
  • JU Health Component
  • Taking Damage
  • Damage Trigger
  • JU Damager
  • Damage by code
  • How to heal a character
  • Health Power Up
  • How to heal by code
  1. Quick Start
  2. How to create a JU Character / Reskin Default Character / Setup New Characters

Taking Damage / Healing

PreviousBody Leaning SetupNextFootstep System

Last updated 1 year ago

JU Health Component

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

Taking Damage

Damage Trigger

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.

JU Damager

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.

Damage by code

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:

DamageOnTriggerEnter.cs
using UnityEngine;
// >> must use JUTPS lib to acess JUHealth component <<
using JUTPS;

public class DamageOnTriggerEnter : MonoBehaviour
{
    [SerializeField] private float Damage = 5;
    private void OnTriggerEnter(Collider other)
    {
        //Get JU Health component
        if (other.TryGetComponent(out JUHealth health))
        {
            //Damage Character
            health.DoDamage(Damage);
        }
    }
}

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.

How to heal a character

Healing a character is as easy as taking damage.

Health Power Up

A Health Power Up Prefab is already included by default that adds some health points to the player:

How to heal by code

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

Regenerate.cs
using UnityEngine;
// >> must use JUTPS lib to acess JUHealth component <<
using JUTPS;

public class Regenerate : MonoBehaviour
{
    [SerializeField] private JUHealth CharacterHealth;
    [SerializeField] private float HealthPointsToAdd = 2;
    
    // Update is called once per frame
    void Update()
    {
        // > Prevents it from continuing to add health points infinitely
        if(CharacterHealth.Health == CharacterHealth.MaxHealth) return;
        
        // > Regenerates health points per second (HealthPointsToAdd)
        CharacterHealth.Health += HealthPointsToAdd * Time.deltaTime;
    }
}

The script above is a simple health regeneration system, it will add HP over time.

It supports Particles and Audio effect, it is the same component used in and

😄
HitBoxes
Malee weapons