OwlyOwl

hitbutton

May 25th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class Hit : MonoBehaviour
  7. {
  8.     [SerializeField] HealthBar _healthBar;
  9.     public int maxHealth = 100;
  10.     public int currentHealth;
  11.  
  12.     private void Awake()
  13.     {
  14.         currentHealth = maxHealth;
  15.         _healthBar.SetMaxHealth(maxHealth);
  16.     }
  17.  
  18.     public void OnButtonClick()
  19.     {
  20.         currentHealth -= 10;
  21.         _healthBar.SetHealth(currentHealth);
  22.     }
  23.  
  24.  
  25. }
Add Comment
Please, Sign In to add comment