this is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class healthsystem : MonoBehaviour
{
private int health;
public int health_max;
// public if you want to drag your text object in there manually
the part here doesn’t work so yeah how can i fix this
public Image bar;
private void Start()
{
health = health_max;
}
void Update()
{
if (health <= 0)
{
Destroy(gameObject);
}
}
public void TakeDamage(int damage)
{
health -= damage;
bar.fillAmount = health / health_max;
//bar.localScale = new Vector3(1/(health/damage)f, 1f));
}
}
any suggestions?