Skip to content

Run-and-gun

For creatorsAdd-on 1.104.0+

In this tutorial you build a side-scroller. A soldier runs right through a jungle of runners and turrets, jumps two pits and two walls, picks up a spread gun, and breaks the core of the wall at the end. Everything new is a tag: the side view, the platform body, the follow camera, sprite mirroring and parallax. The aiming uses vector nodes you already have. This builds on tutorial 10, Blueprints and the Inspector.

▶ Play the finished game: ← → run, Space jumps (hold for a full jump, tap for a hop), J fires, ↑ aims up (diagonally while running), ↓ drops through a ledge, R plays again. On a phone, use the pad: ◀ ▶ ▲ ▼ ⤒ ✶.

Every arcade game so far was a board seen from above: bodies collide on the floor plane and height is ignored. A platformer is seen from the side.

  1. Save a new file as run-and-gun.blend.

  2. In Properties ▸ Scene ▸ Custom Properties, add arcade.plane = xy. Bodies now collide with x to the right and y up, and depth is ignored.

  3. Build the level in Blender’s front view (Numpad 1): you see it the way it plays. Ground runs and solid steps are Arcade Solid; the pit under the screen is an Arcade Sensor in the layer pit.

  4. Make ledges and a bridge you land on from above and pass through from below or the side: Arcade Solid with arcade.oneway = 1.

The player is an ordinary Arcade Mover with more tags.

Tag Value What it does
arcade.gravity 0,-32,0 Pulls the body, in m/s²
arcade.collide 1 Solids stop it instead of bouncing it: it lands on floors, bumps its head on ceilings and halts at walls. Landing against gravity makes it grounded
arcade.drive · arcade.driveSpeed move · 5.5 Running
arcade.jump · arcade.jumpSpeed jump · 13 Jumps when grounded
arcade.maxFall 18 The fastest it falls, m/s
arcade.drop down Falls through the one-way ledge it stands on
arcade.layer · arcade.hits player · enemy,ebullet What it is, and what harms it
arcade.grace 2 Seconds safe from harm after a reset
sprite.mirror 1 The drawing flips to face the way the body faces

Three things make the jump feel right, and all three are built in: a press up to 0.12 s before landing is remembered, a jump up to 0.1 s after walking off a ledge still counts, and letting go while rising cuts the jump short. A held jump peaks at exactly v²/2g, here 13² ÷ 64 ≈ 2.64 m, at any frame rate.

Grace means safe from harm. During arcade.grace, only the layers in arcade.hits are ignored. Pickups, checkpoints and the pit still report, so a respawned player never falls forever.

  1. Draw the soldier as a four-frame sprite sheet and give the player Sprite with sprite.frame = anim, so the rules pick the frame.

  2. Give it Arcade Mover and the tags above. Graphs can ask it grounded and facing (−1 or 1) with Call Component.

  3. In World ▸ Simulacrum ▸ Input, add move = keys:ArrowLeft/KeyA,ArrowRight/KeyD, up = keys:ArrowUp/KeyW, down = keys:ArrowDown/KeyS, jump = keys:Space/KeyK/KeyZ, fire = keys:KeyJ/KeyX/Enter ; repeat:160,160 and again = keys:KeyR/Enter.

  4. Add a pad menu (hud.layout = pad, shown while playing) with move@-1=◀|move@1=▶|up=▲|down=▼|jump=⤒|fire=✶. An option such as move@-1 holds an axis action at that value.

  1. Build the runner as a spawnable (rg-runner.blend): an Arcade Mover with the same arcade.gravity, arcade.collide and arcade.maxFall, plus arcade.patrol = 2.2 (it walks along x, turning at walls), arcade.ledge = 1 (it turns at ledges too, so it never walks off) and arcade.patrolDir = -1. Its layer is enemy and it hits player.

  2. Build a turret spawnable with its own small graph: every 2.2 s, if the player is within 10 m (Vector Measure, distance), it fires along normalize(player − self) × 5 (Vector Math: sub, normalize, scale) and hands the spawned bullet that velocity with setVelocity.

  3. Build the player’s shot and the enemy bullet (layer ebullet) the same way, and list all four in spawn.preload.

  4. Put the enemies in a data table, data/enemies.json, with each enemy’s spawnable address in asset and its place in x and y. The rules spawn them at every new game, so Play again puts every enemy back. The player, the spread-gun pickup and the boss are placed in the level.

Set the camera in Properties ▸ Scene ▸ Custom Properties (they then show in World ▸ Simulacrum ▸ Camera), starting from a fixed orthographic side view (camera.mode = fixed, camera.projection = ortho, camera.at = 6,3,30, camera.target = 6,3,0, camera.orthoHeight = 5.4).

Tag Value What it does
camera.follow Player Tracks that object, keeping the authored offset
camera.followLead 2 Looks 2 m ahead in the way it moves
camera.followMin · camera.followMax 6,3 · 104,3 Keeps the level’s ends on screen
camera.followOneWay 1 Never scrolls back
camera.followEase 6 (default) How fast it catches up
camera.followAxes x (default) xy tracks height too

A respawn at a checkpoint moves the player more than 3 m in one frame; the view snaps there and starts its one-way scroll again from that point.

Three drawn layers stand behind the level: the sky, far ridges and near jungle. Give each Sprite a sprite.parallax: 0 for the sky (it rides with the camera), 0.25 for the ridges and 0.55 for the jungle. Each moves by 1 − parallax of the camera’s travel, so it seems that far away. Use sprite.tile to repeat a layer along a long level.

  1. Aim. Keep aimUp (from up) and moveX (from move), and ask the player’s facing. One formula gives the direction: ahead, straight up, or diagonal while running.

  2. Fire. Spawn a shot at the muzzle and give it setVelocity. With the spread gun, fire a For Loop of three shots at −14°, 0° and +14°.

  3. Checkpoints. Touching a flag (an Arcade Sensor) raises checkX. After a lost life, call reset on the player with "x,y,z" at the checkpoint: its home moves there, and every later reset returns to it.

  4. The boss is a wall with a core. Count 12 hits on it, and while the player is in the arena, fire a three-way aimed volley.

  5. The end. Out of lives, or the core broken, ends the game and keeps the best score.

  1. Press Build Cartridge and publish the game with its four spawnables (Publish and share).

  2. Open it and run right: the camera leads you, the hills slide by slower than the ground, and a held jump clears the first pit.

While a game’s camera owns the screen, the page’s button for entering a headset sits small in the top-right corner, out of the pad’s way.

The Expression node has no sine or cosine. Write an angle’s values into the formula as numbers, as the spread gun does for its ±14° fan.

  • arcade.plane = xy makes a side view built in Blender’s front view.
  • The platform body: gravity, collide, a forgiving jump, one-way ledges, drop-through and patrols.
  • The follow camera and parallax layers carry a long level.

Next: Hover racer gives the arcade mover grip, a brake and a chase camera.