How do I spawn a random object

Get help using Construct 2

Post » Sat May 03, 2014 3:28 pm

So I want to spawn enemies every 3 seconds ( which i know how to do ) but how do i spawn random enemies. So I have 3 different enemies, how do i spawn different one from the same spawn ( it must be the same spawn )
Thanks in advance.
B
7
S
2
Posts: 102
Reputation: 975

Post » Sat May 03, 2014 4:13 pm

You would have to have a number represent each enemy and have a global variable that holds a random generated number to choose which one to spawn. Then have a event for each possible number to tell it which one to spawn.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sat May 03, 2014 4:19 pm

I would use local variable instead of a global one, because You only need it to spawn some objects on specific event and there's no need to have it available for entire project.
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,599
Reputation: 34,825

Post » Sat May 03, 2014 5:05 pm

You can also put the enemies into an "Enemies" family and pick them randomly either with the "pick random instance" expression or using the the "pick by evaluate" expression and a Family variable.

See attached file.
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Sat May 03, 2014 8:17 pm

Yes local not global. I didn't recommend families cause they don't have a license from their profile info. Which isn't available in the free version.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Sun May 04, 2014 1:32 pm

Thanks, that really helped.
B
7
S
2
Posts: 102
Reputation: 975


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish and 14 guests