I have a score feed, which displays a text that says “15+” when ever i kill an enemy, but the problem is, if i shoot multiple enemies in a small time range it will just show “15+” throughout it, so it would be hard to distinguish between each kill. I want it to double whenever i get multiple kills within a certain time range (i know it says multiply in the title, but it looks better.). Here is an example from CoD: best cod feeds ever. - YouTube
I’ve searched it up, but i still can’t find a good solution, i’ve been pondering for a while now.
XP feed code, that pops up a text (saying 15+) whenever i kill someone:
public class XpFeed : MonoBehaviour {
public float showtime;
Text text;
public int xpFeed;
void Awake()
{
// Set up the reference.
text = GetComponent<Text>();
// Reset the score.
}
void Update()
{
// Set the displayed text to be the word "Score" followed by the score value.
text.text = "+" + xpFeed + "xp";
}
public void getFeed()
{
StopCoroutine("showfeed");
text.enabled = true;
StartCoroutine("showfeed");
}
public IEnumerator showfeed()
{
yield return new WaitForSeconds(showtime);
text.enabled = false;
}
}
And enemy AI code:
public class AIHealth : MonoBehaviour
{
public int xpValue = 15;
public GameObject xpfeed;
void Awake()
{
xpfeed = GameObject.Find("XPFeed");
}
void Death()
{
XPManager.curXp += xpValue;
xpfeed.GetComponent<XpFeed>().getFeed();
}
}