Pick one at random

Out of all the aliens, choose one, so only that one shoots or turns into a power-up.

The idea

Normally a condition like Every 2000 ms is not about an object, so an action on Alien happens to every alien. Twenty aliens all shoot at once. That is a lot of lasers.

Pick one of them at random narrows it to one. It is under Pick or count in a sprite’s tests. Add it to a rule and the actions only happen to one copy, chosen at random each time the rule runs.

WhenEvery 2000 msPick one Alien at random
DoAlien shoots Laser at Ship (speed 50)

How to

  1. Make the rule’s first condition, for example ⏱ Timer → Every → 2000.
  2. Click + and… at the end of the row.
  3. Click the sprite (Alien), then Pick or count → Pick one of them at random. Press Add.
  4. Click the cell under Alien and add the action.

Where it is useful

A random shooterEvery two seconds, one alien fires at the ship instead of all of them.
A random power-upWhen a brick breaks, pick one of the remaining bricks and change its animation to “gold”.
A random doorAt the start of the level, pick one door and turn its switch on. That is the real exit.
A random bonus coinPick one coin and make it flash so the player chases it.
WhenStart of levelPick one Door at random
DoTurn switch 0 of Door on

Picking after picking

If a condition before it already picked some copies, the random pick chooses from those. “Hero is closer than 200 pixels to Ghost” then “Pick one Ghost at random” chooses one of the near ghosts only.

Random numbers instead

Pick one at random chooses an object. If you want a random number, like a random place or speed, use the Random function in a number box. Random(10) gives a whole number from 0 to 9. See Random.

Still stuck?

Try the Chocobreak tutorial, open a sample game and read its rules, or look at the questions people ask.