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.
How to
- Make the rule’s first condition, for example ⏱ Timer → Every → 2000.
- Click + and… at the end of the row.
- Click the sprite (Alien), then Pick or count → Pick one of them at random. Press Add.
- Click the cell under Alien and add the action.
Where it is useful
| A random shooter | Every two seconds, one alien fires at the ship instead of all of them. |
|---|---|
| A random power-up | When a brick breaks, pick one of the remaining bricks and change its animation to “gold”. |
| A random door | At the start of the level, pick one door and turn its switch on. That is the real exit. |
| A random bonus coin | Pick one coin and make it flash so the player chases it. |
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.