Array issue. Need help.

Get help using Construct 2

Post » Fri Oct 04, 2013 9:15 am

Hi,

I want to generate random objects at a particular interval. This is what I have done:
1. I have created one object.

2. Added animations to that, which are the other objects that I want to appear randomly.

3. Created an array.

4. On Start of Layout, <array name> push back <animation name> on X axis. I did this for all the animations.

5. System > Every 0.7 seconds > System > Create Object <object name> on Layer 1 at <co-ordinates>

6. <Object name> > Set animation to arrayName.At(floor(random(arrayName.Width))) (play from beginning)

But my problem is, though all the animations appear randomly, almost 90% of the time, just the first animation keeps spawning.

How can I make it that everything is random and one object is not overly dominated?

Thanks.
B
5
S
1
Posts: 38
Reputation: 839

Post » Fri Oct 04, 2013 9:26 am

The first thing that comes to mind is if you've set the width of the array correctly? If you add an array it is set to (10, 1, 1) initially. You can access the values in the array's tab, or via event prior to pushing the animation names.
If it is set to 10, then any push adds to the size, and when randomizing it will select the first ten cells a lot more often than your animation entries.tulamide2013-10-04 09:27:26
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Fri Oct 04, 2013 8:47 pm

Amazing! Thanks! Yeah. I reduced the width to the number of animations I had added and now its fine. :)
B
5
S
1
Posts: 38
Reputation: 839


Return to How do I....?

Who is online

Users browsing this forum: plinkie, rayolf and 6 guests