I have an enemy script, the enemy (target) has health and all.
When the enemy dies I have an animated text that plays (it's a +100 text that shows the player that they just got a 100 score points.
It works perfectly fine, except when you kill 2 enemies in a very short time in-between.
When one enemy is dead the animation plays, but if you kill another enemy while the animation is still playing the animation doesn't play for the second kill.
(I want it to be just the the "+Score" from MW3, the game inspired me the learn making games and I'm starting to get better at coding (very slowly).
Here's the script:
using UnityEngine;
public class Target : MonoBehaviour
{
public float health = 100f;
public AudioSource hitMarkerSound;
public GameObject hitmarker;
public Animator plusScore;
private bool animIsPlaying;
public AudioSource deathSound;
public void TakeDamage (float amount)
{
hitMarkerSound.Play();
health -= amount;
hitmarker.SetActive(true);
if (health <= 0f)
{
Die();
}
}
void Die()
{
Scooree.score += 100;
plusScore.Play("+100Score");
deathSound.Play();
Destroy(gameObject);
}
}
↧