How do I randomly spawn objects on other objects?

Get help using Construct 2

Post » Fri Dec 12, 2014 7:30 pm

It's pretty easy to spawn objects randomly inside the window.
However, I want to spawn objects only on the ground on various platforms (side scroller).

Should I place invisible boxes on various places that they can spawn in? How would I go about doing that?

Black are platforms and green is where I want to spawn enemies:
Image

https://www.dropbox.com/s/r15woy48zsrih2t/Untitled-1.jpg?dl=0
Last edited by jook00 on Fri Dec 12, 2014 8:38 pm, edited 1 time in total.
B
58
S
19
G
3
Posts: 445
Reputation: 6,300

Post » Fri Dec 12, 2014 7:55 pm

The image isn't displayed.

To "spawn" sprites like the way you describe, I like to use this method.

I create a square sprite that is invisible or covered by the sprite it spawned by "setting the position to object" and spawn an enemy or a bonus. I use that so you can set a random time or a random object to spawn via a global variable.

The "difficulty" would be to set a specific mouvement from your sprite. But maybe with the photo it will be clearer.
B
7
S
1
Posts: 31
Reputation: 689

Post » Fri Dec 12, 2014 8:38 pm

B
58
S
19
G
3
Posts: 445
Reputation: 6,300

Post » Sat Dec 13, 2014 8:22 am

figured it out. i have an invisible object (spawnobj) and invisible spawnmarker. i have the spawn object move every second at random locations. when it finally moves over the spawn marker, it spawns the enemy.
B
58
S
19
G
3
Posts: 445
Reputation: 6,300

Post » Thu Dec 18, 2014 10:57 pm

I use that line:

Let say you have a spawner and multiple enemies. Add a variable to those enemies and pick a value for them, I called it Enemychoice here.
It's just in order to make your spawner choose randomly between multiple ennemies.


{_System// Every random(X1,X2) seconds---------------------Spawner01// set Enemychoice to choose 1,2,3

{_Spawner01//Enemychoice=1--------------------------Spawner01// Spawn E1 on layerA(image point0)
_Spawner01//Enemychoice (different as(the symbol isn't on my keybord))0------------------------Spawner01//set Enemychoice to 0
_System//trigger once.

{_Spawner01//Enemychoice=2--------------------------Spawner01// Spawn E2 on layerA(image point0)
_Spawner01//Enemychoice (different as(the symbol isn't on my keybord)) 0------------------------Spawner01//set Enemychoice to 0
_System//trigger once.

{_Spawner01//Enemychoice=3--------------------------Spawner01// Spawn E3 on layerA(image point0)
_Spawner01//Enemychoice (different as(the symbol isn't on my keybord))0------------------------Spawner01//set Enemychoice to 0
_System//trigger once.
B
7
S
1
Posts: 31
Reputation: 689

Post » Fri Dec 19, 2014 1:54 am

Thank you!
B
58
S
19
G
3
Posts: 445
Reputation: 6,300


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests