Spawn a random object

Get help using Construct 2

Post » Mon Feb 09, 2015 12:12 pm

How is that done ?

Cheers
B
28
S
15
G
10
Posts: 337
Reputation: 7,835

Post » Mon Feb 09, 2015 12:49 pm

Simple way would be to put all objects into one family and then spawn family.
Last edited by razorMonkey on Mon Feb 09, 2015 12:51 pm, edited 2 times in total.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 12:51 pm

razorMonkey wrote:Simple way would be to put all objects into one family and then spawn family.


What is the other way for free users?
B
7
Posts: 23
Reputation: 321

Post » Mon Feb 09, 2015 12:52 pm

Other way would be with compare values, for example:
if rand(100) > 50 = spawn object1
else = spawn object2
means you have 50% chance for object1 and if it fails 100% chance for object 2

EDIT
This is all pretty basic and crude but it works with basic functions, maybe there is some more elegant way.
Other way, if you want all objects to have same spawning chance, is to create variable and then put random number into it: vrandomVariable = random(number of objects)"
And then for every object put one condition like

if randomVariable = 1 - spawn object1
else
if randomVariable = 2 - spawn object2
else
if randomVariable = 3 - spawn object3
and so on
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 3:25 pm

Hi thanks for reply

In my case I have a sprite ( SpawnerBox )
- that has to spawn random between 4 diff sprites ( Slice1,Slice2,Slice3,Slice4)

and is ther a way to shuffle on event ... like shake
B
28
S
15
G
10
Posts: 337
Reputation: 7,835

Post » Mon Feb 09, 2015 4:58 pm

flemmig wrote:and is ther a way to shuffle on event ... like shake

Wait, do you need to spawn each of them only one time, just in random order?
Because with my example it can give same slice twice or even more times.

And what do you mean by shuffle? Do you have capx of that project?
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Feb 09, 2015 5:20 pm

Yepp .. only ones on start of layout :-)
B
28
S
15
G
10
Posts: 337
Reputation: 7,835

Post » Mon Feb 09, 2015 7:29 pm

Looks like we have this discussion going on here as well: how-do-i-create-a-good-spawn-system_t124560
B
21
S
4
G
1
Posts: 96
Reputation: 1,852

Post » Mon Feb 09, 2015 8:24 pm

flemmig try this
You do not have the required permissions to view the files attached to this post.
B
226
S
31
G
14
Posts: 1,899
Reputation: 38,302

Post » Mon Feb 09, 2015 10:20 pm

> Lordshiva1948

Thanks!!! - Helped me a lot :-)

Is there at way to set random angle ... eg stepping 90 degres
B
28
S
15
G
10
Posts: 337
Reputation: 7,835

Next

Return to How do I....?

Who is online

Users browsing this forum: Morcego and 9 guests