[SOLVED] Game Development 3: How to Track Enemies Defeated?

I cannot track the number of enemies my hero defeats for some reason, but I am able to track the number of coins collected. Here is my code for enemies defeated and coins collected.

ui.track(game, "defeated")
ui.track(game, "collected")
hero.on("defeat", onDefeat)
def onDefeat (event):
    game.defeated = 0
    unit = event.target
    item = event.other
    if unit.type == "ogre" or unit.type == "munckin" :
        game.defeated += 1
game.collected = 0
hero.on("collect", onCollect)
def onCollect(event):
    unit = event.target
    item = event.other
    if item.type == "gold-coin":
        game.collected += 1

If this line is in the onDefeat, the defeated will be only one and never go up. To fix that error, put this before the onDefeat.
Do you need any more assistance at this level?

1 Like

No, thank you for your help!