How to determine if there not any enemies


#1

How do you see if there is no enemys


#2

I think you use
if enemy = null:


#3

You can use a super simple if statement.

if enemy:
    #hero.strike(enemy)

Basically if enemy has any thangs (enemies/ objects) in it will run the code afterwards.
-Cheers


#4

Well, before saying “if enemy”, you need a variable, enemy = hero.findNearest(enemies). At least thats what I use. Hope you knew. :+1::slight_smile:


#5

True, my apologies, I assumed that enemy = hero.findNearest(hero.findEnemies) was out of the questions scope.
-Cheers


#6

Thank you i’m new to the game :relaxed:


#7

Just to tie up loose ends:

enemies = hero.findEnemies()
enemy = hero.findNearest(enemies)

if enemy:
    hero.attack(enemy)