# Creating Enemies randomly starting from 3 fixed position

Hi,
I have 3 fixed position A,B, C (these positions are in different X,Y coordinates).
I have to create enemies every 10 seconds randomly from position A, B or C.

Someone can help me on that?
thanks a lot in advance

There is a few ways to do this.
You may could have a variable swap to a random value every 10 seconds and then make it spawn depending on the variable.
Hopefully this can help.

The events 2,3,4 should be sub-events of 1

I have tested it using the code in the sub-event and it works fine!!!

thanks a lot my friends

â€¦the only doubt that I have if the random function will generate also 0 or notâ€¦
Random (2) will generate 1 and 2 or 1,2 and 0?

thanks in advance

Random(2) should generate 0, 1 , and 2.
It spawned 3 enemies over time in three different places, when I tried it.

Hi,

I need to be sure that when the enemy is created in one of the wanted position, the random function will not generate the enemy in a position already busy ().
Example
I have Enemy1, Enemy2, Enemy3
Position1, Position2, Position3
The random function generate Enemy1 in Position2
If Position2 is busy by Enemy1 (because was not fired) the random function should chose Position1 or Position3

Any suggestion?
Please can you help me?

Itâ€™s a bit complex if you never did it before, but basically this what i would do :

• add variable â€śoriginâ€ť to the object â€śEnnemyâ€ť, wich take the value of origin point (1/2/3)
• in the event where you generated the ennemy objects check the variable values and the numbers of object : the idea is to limit to one object with variable â€śoriginâ€ť conform to your spawn point for each spawn point

There are other ways, but itâ€™s the simpliest i have in mind.

1 Like