Random spawn locations

I am trying to have waves of enemies coming at the players randomly, i have the spawn extension.


i have several spawners, i would like to pick a random spawner to create the enemy.

right now it just create an enemy at every spawners at the same time.

I have not worked with the spawn extension, but I am sure you would be able to assign a variable to each spawner. So make a var spawn on each one, and set it from 0-4 (lets say that you have 5 spawners. When the wave is to be triggered, select a scene Variable(spawnplace)= RandomInRange(0,4) then on your code set a"And" condition, and below its hierarchy include “pick all spawners” and variable spawn of spawners = scene Variable(spawnplace). that should choose just one of your spawners. Like I said, I haven’t used the spawn extension, but it should work as long as you can have that variable on the spawner. And be sure to trigger once for each wave , or you might be swamped with enemies. Hope that helps and makes sense :slight_smile:

so i need to create several object spawners? i was hoping i could just use one object then pick a random one.

But you said you had several spawners in the scene. And it looks like snobunni is showing you how to just pick one.

1 Like

i created i spawner, called it “spawn” then dragged 4 instance of it in the scene.

when i change the variable of one, it changes to all because they are all the same object, or maybe i missing something.

Hi, Did you set the variable on the object in the object window (kind of the main one where you add the animation. behaviors, variable?) That’s ok, they will all have the same one then. But you can adjust that here:

to be different for each one. You don’t need but one object, each instance can have its own variable. I hope that clears it up a little :slight_smile:

yes, that clears it up, thank you.

that opens up some new possibilties. :smile:


Ooooooh I gotcha now. I was confused for a minute lol, but I see you meant did you need to make multiple objects of the same sprite.

is it possible to randomize conditions?

have like a “pick one”
then several sub conditions

I’m not familiar with the spawn behavior. It seems to treat each instance as a separate emitter. You could probably modify the behavior or add a bunch of conditions but I would just add a timer and do it without the behavior. You could use a random SpawnPoint or the one Nearest to the player.