How to spawn object at random specific positions

Get help using Construct 2

Post » Sun Sep 01, 2013 12:34 pm

Hi there,

Currently I have 4 spawn points. In fact, it is an object called "spawnPoint". This object has an instant variable called "position". I set the position for each spawnPoint from 1 to 4.

Now I want for each 2 seconds, spawns a new object from 1 of these 4 points. I do not know how to do it.

Cheers,
B
10
S
4
G
2
Posts: 36
Reputation: 2,207

Post » Sun Sep 01, 2013 1:41 pm

make a global (or local) variable first, lets call it "whichspawn"

Condition:
system - every 2 seconds

action
whichspawn = int(random (1,5))
system/
create object yourobject at location whichspawn.X, whichspawn.Y

something along these lines. I hope I could help.
Regards;
-Wind.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Mon Sep 02, 2013 2:28 am

[QUOTE=Windwalker] make a global (or local) variable first, lets call it "whichspawn"

Condition:
system - every 2 seconds

action
whichspawn = int(random (1,5))
system/
create object yourobject at location whichspawn.X, whichspawn.Y

something along these lines. I hope I could help.
Regards;
-Wind.
[/QUOTE]

Hi Windwalker,

Thanks for your help. According to your suggestion, I solved out my issue. However, the actually code is a little bit different:

Condition:
system - every 2 seconds

action
whichspawn = int(random (1,5))
system/
create object myObject at location myObject(whichspawn).X, myObject(whichspawn).Y

Hope that will help other people as well.

Cheers,
B
10
S
4
G
2
Posts: 36
Reputation: 2,207

Post » Mon Sep 02, 2013 3:11 am

Pick a random instance of spawnPoint then create the new object at spawnPoint
B
47
S
14
G
7
Posts: 603
Reputation: 8,141


Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 22 guests