Spawn enemies in a random specified location

Get help using Construct 2

Post » Fri Mar 02, 2012 4:48 pm

Hi!
I'm trying to make enemies spawn randomly in a specified location but i can't get it to work, for example:
I have a sprite called Spawn and then i duplicated it all over the map, until here is all fine but when i do System -> Every 5 seconds -> Create Object Enemy on layer 0 at (Spawn.X , Spawn.Y) it always creates the enemy always in the first spawn and not in the others ,
I tried to change the (Spawn.X , Spawn.Y) to (random(Spawn.X) , random(Spawn.Y)) but it also doesn't work (enemies never spawns).
Can anyone help me?
Thank you ^^


[QUOTE=smitchell] you can use the choose operator like this:

System.Every 5 Seconds:
     -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

Hope that helps! [/QUOTE]

Here is the cap with smitchell idea(thanks): http://dl.dropbox.com/u/18148396/spawn2.capx
Here is the cap without smitchell idea (which only spawns in 1 location): http://dl.dropbox.com/u/18148396/Spawn.capx diogofaria2472012-03-02 19:28:12
B
15
G
1
Posts: 11
Reputation: 986

Post » Fri Mar 02, 2012 6:27 pm

You can make it using an overlapping conditional, when the spawner is overlapping the "invisible area of spawn" sprite, it can shot the enemies ^^
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Fri Mar 02, 2012 6:41 pm

Post a .capx so more people could take a look. It's hard to know the problem with just the explanation
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Fri Mar 02, 2012 6:47 pm

you can use the choose operator like this:

System.Every 5 Seconds:
     -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

Hope that helps!
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Mar 02, 2012 7:19 pm

[QUOTE=smitchell] you can use the choose operator like this:

System.Every 5 Seconds:
     -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

Hope that helps! [/QUOTE]

Hmm... smitchell the way you said it works but if i have for example 50 spawns positions and for some reason i have to delete or change the spawn location i will have to look every 50 positions to see which one that i need to change in the event sheet

[QUOTE=7Soul] Post a .capx so more people could take a look. It's hard to know the problem with just the explanation[/QUOTE]

Here is the cap with smitchell idea(thanks): http://dl.dropbox.com/u/18148396/spawn2.capx
Here is the cap without smitchell idea (which only spawns in 1 location): http://dl.dropbox.com/u/18148396/Spawn.capx

[QUOTE=TELLES0808] You can make it using an overlapping conditional, when the spawner is overlapping the "invisible area of spawn" sprite, it can shot the enemies ^^[/QUOTE]

I think i didn't understood what you said or you didn't understood what i asked
Thanks anyway diogofaria2472012-03-02 19:22:50
B
15
G
1
Posts: 11
Reputation: 986

Post » Fri Mar 02, 2012 9:54 pm

[code]System:Every 5 seconds
System:Pick random Spawn instance
-> Create Object Enemy on layer 0 at (Spawn.X , Spawn.Y)[/code]Yann2012-03-02 21:55:01
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Mar 02, 2012 10:21 pm

[QUOTE=Yann] [code]System:Every 5 seconds
System:Pick random Spawn instance
-> Create Object Enemy on layer 0 at (Spawn.X , Spawn.Y)[/code][/QUOTE]

Thank you!!!! It worked!


Thank's to everyone who tried to help !
B
15
G
1
Posts: 11
Reputation: 986

Post » Thu May 31, 2012 8:32 pm

Good info! Like for spawning random bullets as asteroids.
B
5
Posts: 38
Reputation: 501

Post » Tue Jul 17, 2012 6:48 am

What else, if i want to spawn enemies and i want my enemies go from A to B, and die in B.
B
3
Posts: 1
Reputation: 277

Post » Sun Jul 21, 2013 6:49 pm

[QUOTE=smitchell] you can use the choose operator like this:

System.Every 5 Seconds:
     -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

Hope that helps! [/QUOTE]

I want to ask if there is anyway to spawn enemies at different spawns WITH many duplicated objects. I have created a 'spawn' object, duplicated it all over the map, but the choose function has to have two or more parameters and that 'spawn' object is the only object for spawning. I wonder how can it spawns randomly but on duplicated objects?
B
4
Posts: 5
Reputation: 210

Next

Return to How do I....?

Who is online

Users browsing this forum: christina and 6 guests