You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
687 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using StarterAssets;
using TMPro;
public class Player : MonoBehaviour
{
public int MaxHp = 100;
public int Hp = 10;
public GameObject HpBar;
public GameObject HpText;
// Start is called before the first frame update
void Start()
{
SetHp();
}
public void SetHp() {
HpBar.GetComponent<Slider>().value = Hp;
//Debug.Log(HpBar.GetComponentInChildren<TextMeshPro>().text);
HpText.GetComponent<TextMeshProUGUI>().SetText(Hp + "/" + MaxHp);
}
// Update is called once per frame
void Update()
{
}
}