How to spawn enemy's over time

Need help making enemy’s spawn overtime on the left and right side of my map

2 Likes


See those gaps in the border? Create two different spawner objects, one on the left gap and one on the right gap. Next, delete the enemy already on the map and move the player to the middle of the screen. Then, put this code in the first spawner:
image
Make sure the Emit behavior is set to “don’t expire” or the enemy will kill itself. You can change the time in the Timer behavior to control when the enemy spawns. The Once behavior makes the enemies spawn when the game starts. If you don’t want that, just delete the Once behavior block. On the left spawner, change the spawner object’s forward direction to right. On the right spawner, change the spawner object’s forward direction to left. This will make sure that the enemy spawns in map and not outside it. In the Timer behavior, the number 10 means 1 second. Keep that in mind when choosing the repeat delay (I recommend 100 for a simple game like this). Make sure the Timer is set to repeat forever.

2 Likes

Using the Spawn behavior can also be used instead of an Emit. It’s not needed here, but when spawning things it’s a good habit to almost always use Spawn.

2 Likes

Yeah but that can be imprecise. Just look at the motorcycle spawn in Gamougg 4 level 7.

Spawn is as precise as you want it to be. You put in the exact X and Y chords you want to spawn it at. If you input you objects X and Y cords it will spawn straight on top of you, but if you displace it a little it can spawn exactly like an emit

2 Likes

Hey, i’m sorry but i’m very new to flow lab. So I was just wondering if you could explain in a more simple way?

2 Likes

Were you talking to me or john? If you were talking to me,

If you have an object you can get its X and Y position with an Extractor (this can be found in the Properties section). If you input those X and Y values into the Spawn behavior then the object selected in the Spawn will be spawned directly onto the object. You don’t want this, so you would want to spawn it to one of the sides of the object (For this example we’ll say the left side).

To fix this you can use an Expression to adjust the X value (the X value is adjusted because we want to spawn it on the left of an object). Flowlab coordinates work like this, Left is -X, Right is +X, Up is -Y, and Down is +Y.

So to make it spawn to the Left of an object we would need to minus from the X value. To do this, in the Expression you could have something like ‘A-32’, A is the X value and the number next to it is the number of pixels you want it to be in that direction.

Is that better? If not I’ll try rewriting it in a better way.

My way works if you change the enemies to be physically movable