Hello everyone, first, I want to say that Im sorry but my english is not the best and I hope you will understand what Im about to ask.
I started working on my first project ever (Soo, still learning), and I got into problem.
I was coding enemy and everything is good, I watched some video on yt, actually, few of them, trying to find answer but I couldn't.
When I start game, my enemy wont get his current health up to 100, it says "maxHealth 100, currentHealth 0" in debug mode, and he die with just one hit even if my attack damage is 25.
Well, here is my code:
public class Enemy : MonoBehaviour
{
public Animator animator;
public int maxHealth;
int currentHealth;
// Start is called before the first frame update
void Start()
{
currentHealth = maxHealth;
}
public void TakeDamage(int damage)
{
currentHealth -= damage;
//play hurt animation
animator.SetTrigger("Hurt");
if(currentHealth <=0)
{
Die();
}
}
void Die()
{
Debug.Log("Enemy Dead!");
animator.SetBool("IsDead", true);
Thanks everyone.