How do I randomly choose premade objects?

Get help using Construct 2

Post » Sat Mar 28, 2015 7:47 pm

I have a set of premade objects. The objects move across the screen at X speed. I want to make it so whenever the current object on screen reaches X on the X-axis it will randomly pick one of the other premade objects to begin behind it to create a infinite loop but with random order by which the objects appear.

Say I have 'ground1' moving across the screen, once it reaches X on the X-axis, I want it to randomly choose one of the other objects from a list to create a object following 'ground1' such as 'ground4' and when 'ground4' is at X to load another random 'ground' object to follow it.

Thanks in advance.
B
3
Posts: 7
Reputation: 189

Post » Sat Mar 28, 2015 10:07 pm

If they are different types of objects, you can add them to a family, and if you spawn from that family, it randomly chooses one.

Without the full version, you can use a local variable and assign it a value with floor(random(2)) and then If var == 0 spawn ground0; elseif var == 1 spawn ground1 elseif var == 2 spawn ground2 etc.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Sun Mar 29, 2015 12:19 am

bladedpenguin wrote:If they are different types of objects, you can add them to a family, and if you spawn from that family, it randomly chooses one.

Without the full version, you can use a local variable and assign it a value with floor(random(2)) and then If var == 0 spawn ground0; elseif var == 1 spawn ground1 elseif var == 2 spawn ground2 etc.

Makes sense. Thanks. Looks like its time to purchase a license.
B
3
Posts: 7
Reputation: 189


Return to How do I....?

Who is online

Users browsing this forum: VictorPekarskiy and 1 guest