im still beginner in Unity…
so i have this script to set my Health Bar but it doesnt fit with float var. what logic should i use to this? ( i know i should change " healthBar.SetMaxHealth(); " logic but i dont know what code to use for it. Any suggestion?
using UnityEngine;
public class Enemy : MonoBehaviour
{
public float startHealth = 50f;
private float health;
[Header("Unity Stuff")]
public HealthBarScript healthBar;
private void Start()
{
health = startHealth;
healthBar.SetMaxHealth(startHealth);
}
public void TakeDamage (float amount)
{
health -= amount;
if (health <= 0f)
{
Die();
}
healthBar.SetHealth(health);
}
void Die()
{
Destroy(gameObject);
}
}