Voxel Game Maker

Docs Tutorials

Switches, moving platforms and traps

A lever that opens a gate, a rule that reacts to it, platforms that carry you and traps that hurt.

In the editor: Welcome ▸ Tutorials ▸ 2.2 ▸ ▶ Start goes on in your My Playground project with this lesson's checklist.

Build · about 30 minutes · Basic mode

What you'll make: a lever that opens a gate, a platform ride across a gap, a pressure plate that starts a second platform, and a trap that bites.

What you'll learn: switches, and your first Rules: When something happens, Only if something is true, Do something.

Before you start: do Make it do something: behaviors and triggers. Keep that project open, or start a new one and choose Create ▸ Add Starter Models: the models below are all in that set.

#1. A lever that opens a gate

  1. Place a Torch to be the lever. In Properties, under What is it?, pick Switch and set its Type to Lever.
  2. Place the Locked gate in a wall. Make it a Door and set its Type to Opens with a switch. Its Switch says lever: the same name the lever sets, so they work together at once.

Play it now: walk up to the lever and press E. The gate opens.

#2. A rule that reacts

A rule is one line of logic on an object: When something happens, Do something.

  1. Select the gate. In Properties ▸ Rules, click + Add a rule.
  2. Set When to a switch turns on. Its Switch box says lever.
  3. Tick Only once.
  4. In Do, change the action to Show text (banner) and type The gate is open!.

Play it now: pull the lever. The gate opens and the banner shows, just once.

#3. A moving platform

  1. Dig a gap or a pool too wide to jump. Place a Wood floor tile at one side. It's the platform.
  2. Make it a Platform with the Type Side to side.
  3. Set Moves sideways (tiles) to the width of the gap, and Seconds each way to how slow you want it.

Play it now: step on. The platform carries you across and back.

#4. A plate that starts a platform

  1. Place a second Wood floor tile, make it a Platform and set its Type to While a switch is on. Type bridge in its Switch.
  2. Place the Pressure plate in front of it. Make it a Switch with the Type Pressure plate, and type bridge in its Switch name.

Play it now: the platform waits. Step on the plate and it starts moving.

#5. Traps that hurt

  1. Place some Spikes and make them a Hazard. Set Damage.
  2. For a hidden trap, place a Grass tile on the grass so it looks like the floor. Add a rule: When the player touches it.
  3. In Do, pick Hurt player and set HP to 20. Click + Add action for Shake screen, and again for Show text (popup) with A trap!.
  4. Place a Checkpoint before the traps, so a fall or a defeat brings the player back there.

Play it now: walk over the spikes, then the hidden tile. Watch the health bar drop.

#Try it yourself

  • Two levers, two gates: give each lever its own Switch name (gate_a, gate_b) and each gate the matching Switch.
  • An elevator: a platform with the Type Up and down that lifts you to a ledge.
  • A stone that gives a Key only after the plate is pressed: a rule with + Only if… Switch is on, a Give item, and a popup under Otherwise.

#Learn more

#Next

Take apart: Logic Lab.