Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. using UnityEngine.UI;
  6. public class HealthBar : MonoBehaviour
  7. {
  8. public HitPoints hitPoints;
  9. [HideInInspector]
  10. public Player character;
  11. public Image meterImage;
  12. public Text hpText;
  13. float maxHitPoints;
  14.  
  15. void Start()
  16. {
  17. maxHitPoints = character.maxHitPoints;
  18. }
  19.  
  20. // Update is called once per frame
  21. void Update()
  22. {
  23. if(character != null)
  24. {
  25. meterImage.fillAmount = hitPoints.value / maxHitPoints;
  26. hpText.text = "HP:" + (meterImage.fillAmount * 100);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement