Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class health : MonoBehaviour
- {
- public int curHealth = 0;
- public int maxHealth = 100;
- public Slider healthBar;
- public Animator Anim;
- void Start()
- {
- curHealth = maxHealth;
- healthBar.value = curHealth;
- healthBar.maxValue = maxHealth;
- }
- void Update()
- {
- float hit = Anim.GetFloat("hit");
- if (hit > 0)
- {
- hit -= Time.deltaTime * 3;
- Anim.SetFloat("hit", hit);
- }
- }
- public void sendDamage(int Damagevalue)
- {
- curHealth -= Damagevalue;
- healthBar.value = curHealth;
- Anim.SetFloat("hit", 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment