eastbayeff

Untitled

Mar 10th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4.  
  5. public class health : MonoBehaviour
  6. {
  7.     public int curHealth = 0;
  8.     public int maxHealth = 100;
  9.  
  10.     public Slider healthBar;
  11.     public Animator Anim;
  12.  
  13.     void Start()
  14.     {
  15.         curHealth = maxHealth;
  16.         healthBar.value = curHealth;
  17.         healthBar.maxValue = maxHealth;  
  18.     }
  19.  
  20.     void Update()
  21.     {
  22.         float hit = Anim.GetFloat("hit");
  23.  
  24.         if (hit > 0)
  25.         {
  26.             hit -= Time.deltaTime * 3;
  27.             Anim.SetFloat("hit", hit);
  28.         }
  29.     }
  30.  
  31.    public void sendDamage(int Damagevalue)
  32.     {
  33.         curHealth -= Damagevalue;
  34.  
  35.         healthBar.value = curHealth;
  36.         Anim.SetFloat("hit", 1);
  37.     }    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment