Damage dealt to the enemy is inconsistent. The score is also is also inconsistent.

The player is now receiving a score by a random multiple of 100 for each zombie killed. I think that would be related to the bug where the damage dealt to the zombies is also inconsistent.
In ScoreManager, a function has been added:

 public void AddScore()
    {
        Debug.Log("Player's Score is " + scoreCount);
        scoreCount += scoreCount + 100;
    }

    }

In NormalZombieHealth, I’m calling the AddScore function on death like so:
if (health <= 0)
{
Debug.Log(“Zombie health is i be dead” + health);
Die();
GameObject score = GameObject.FindGameObjectWithTag(tag: “ScoreManager”);
ScoreManager scoreManager = score.GetComponent();
scoreManager.AddScore();
But I am getting these bugs with the damage the enemy is taking:


As well as a bug concerning the score:



The damage bug and score bug were documented in two separate play sessions, but the three damage messages came from three bullets being fired in the same session, and the scores also came from three zombies being killed in a session.

This is the damage being dealt to the zombies and the inconsistency I was talking about:


These were two bullets fired at the same zombie.

If AddScore is supposed to be adding 100 points to scoreCount, you should have this instead: scoreCount += 100;

3 Likes

This helped my score problem, but the damage outputs are still inconsistent, and when an enemy is killed in three shots the score manager gives 200 points rather than 100.
Edit: In the NormalZombieHealth script, I changed the if statement in NormalZombieHealth:
if (health <= 0) to:

  if (health == 0)

I believe this is more accurate and it also solved my score problem entirely, so that’s a plus, I still have an inconsistent damage output bug though.

Show your code for your damage being dealt…and use code tags. I mean, your first post started out great, but then half way you dropped the code tags and then left off the damage code.

You mean the Take Damage function in NormalZombieHealth?

  public void TakeDamage(int damage)
    {
        Debug.Log("Zombie got hit, current health is" + health);
        health -= damage;

The only reason the code tags were dropped is that I wanted to show the Debug.Log messages I was getting.

Thank you @adamgolden and @Brathnann for helping me with the score bug! The damage bug I solved on my own. Turns out the zombie prefab had two health scripts, which explains the inconsistency of the damage output.

1 Like