Tuesday, September 27, 2022
HomeGame Developmentunity - Triple injury however i need solely as soon as

unity – Triple injury however i need solely as soon as


i’m attempting to make a recreation on unity. I’m kinda new, so this is likely to be a silly query idk. Proper now i’m attempting to break the enemy. The Harm works. The issue is it is going to repeat it till the enemy died however i solely need it to break it as soon as.

    void Replace()
    { 
        if(Enter.GetMouseButton(0) && !isCooldown){
            StartCoroutine(Cooldown());
            Assault();                                                       //ATTACK
        }
    non-public void Assault() {
        anim.SetTrigger("assault");

        Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.place, attackRange, enemyLayers);

        foreach(Collider2D enemy in hitEnemies)
        {
            Enemy.GetComponent<EnemyHP>().TakeDamageEnemy(injury);
            Debug.Log("DamageENEMYYYYYYY");
        }
    }

Harm is a public float with 1. the EnemyHP part has code to take away the hp with the injury. Examined the code out with a debug.log and it certainly does take away the hp with the quantity of harm. However it repeats the TakeDamageEnemy operate
The whole hp = 3. So it repeats the code 3 instances (console reveals the log 3 instances.)
How can i alter it so it is going to solely play it as soon as.

That is my first submit on Stack change, so sorry if i omit any vital info. Reply and i’ll add it

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments