How do I make three objects spawn next to each other in a row of ten?

0 favourites
  • 3 posts
From the Asset Store
Footsteps SFX Three contains 540 sounds of steps and jumps on different surfaces.
  • Hello,

    First off, thank you for your time.

    Secondly, the title explains it all but I will explain it some more below, let's go.

    So I want to make a row spawn (this part works) with ten boxes, red boxes are deadly, green boxes are okay to pass through. Now on spawn a frame gets chosen, frame 0 is red and frame 1 is green. But now they just get randomly placed in the row of ten. So sometimes there are three green boxes next to each other but sometimes they are all green or 6 of the boxes are green.

    So how do I make it so three boxes (max) are green in a row of ten and the three boxes must be next to each other at all times but the position in the row changes on every spawn.

    I hope this is clear, if not please let me know.

    Again, thank you for your time (and help).

    Tagged:

  • Hmm how about this:

    1. Spawn all the boxes in red, give them an instance variable that you set to loopindex (assuming you use a loop for the spawn)

    2. generate a random value from 1 to 8 (ignoring the first and last box on purpose)

    3. Now pick all boxes where randomValue-1 <= instanceVariable <= randomValue+1

    4. Set them to green

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hmm how about this:

    1. Spawn all the boxes in red, give them an instance variable that you set to loopindex (assuming you use a loop for the spawn)

    2. generate a random value from 1 to 8 (ignoring the first and last box on purpose)

    3. Now pick all boxes where randomValue-1 <= instanceVariable <= randomValue+1

    4. Set them to green

    Thanks, I will try this.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)