How do I spawn enemies?

How do I…

I have a game where there is a balancing bar in the middle of the screen and i want to spawn enemies randomly in the platform. How can i do that?

Generally you just create object at position X RandomInRange(Bar.X(),Bar.X()+Bar.Width()-Here put width of enemies) Y Bar.Y()-Here put height of your enemies

In both case height and width do not use expression like Enemy.Width() but actual number you which reflect their width/height

and how do i make them continously spawn?

You could use timer
like at beginning of scene start timer

And make event
Condition
Value of Timer is greater than 1 sec

Action
Reset Timer
Here you shove in create object actions

Or like me use time from start

Add condition and type in search bar compare
Add compare two numbers and in it type

Condition
mod(TimeFromStart(),1) is greater than 0.1
Trigger once

Action
Here you shove in your create object actions

So this mod(TimeFromStart(),1) 1 here means 1 sec
If you make mod(TimeFromStart(),4) it will mean 4 secs

thanks! it works perfectly!

1 Like