Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

CHIP303

2
Posts
1
Topics
A member registered Nov 17, 2017

Recent community posts

Thank you man, I didn't enable script component.... such a stupid mistake hahahahaha :3
I'm going to move to next goal in my project, if I get some more questions I will ask on this post here.
Thank you all again ^_^

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.