Search code examples
classobjectunity-game-engineunityscript

Object enemy in unityscript


I can do in unitycript as an object "enemy" that has "health", "speed" and "stamina". And to delete the object, or several at once?

class enemy {
    health = 100
    speed = 10
    stamina = 200
}

for 0 to 10
{
    enemyBig = new Enemy ()
}


if keydown (space)
{
    delete all.enemyBig 
}

How would this code in unityscript correctly?


Solution

  • To keep track of all your enemies at once, what you need is called an array. There's a good tutorial there: