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: ◀ ▶ ▲ ▼ ⤒ ✶.
1. Turn the board on its side
Section titled “1. Turn the board on its side”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.
-
Save a new file as
run-and-gun.blend. -
In Properties ▸ Scene ▸ Custom Properties, add
arcade.plane=xy. Bodies now collide with x to the right and y up, and depth is ignored. -
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. -
Make ledges and a bridge you land on from above and pass through from below or the side: Arcade Solid with
arcade.oneway = 1.
2. Give the player a platform body
Section titled “2. Give the player a platform body”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.
-
Draw the soldier as a four-frame sprite sheet and give the player Sprite with
sprite.frame=anim, so the rules pick the frame. -
Give it Arcade Mover and the tags above. Graphs can ask it
groundedandfacing(−1 or 1) with Call Component. -
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,160andagain=keys:KeyR/Enter. -
Add a pad menu (
hud.layout = pad, shown whileplaying) withmove@-1=◀|move@1=▶|up=▲|down=▼|jump=⤒|fire=✶. An option such asmove@-1holds an axis action at that value.
3. Add enemies that patrol
Section titled “3. Add enemies that patrol”-
Build the runner as a spawnable (
rg-runner.blend): an Arcade Mover with the samearcade.gravity,arcade.collideandarcade.maxFall, plusarcade.patrol = 2.2(it walks along x, turning at walls),arcade.ledge = 1(it turns at ledges too, so it never walks off) andarcade.patrolDir = -1. Its layer isenemyand it hitsplayer. -
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 withsetVelocity. -
Build the player’s shot and the enemy bullet (layer
ebullet) the same way, and list all four inspawn.preload. -
Put the enemies in a data table,
data/enemies.json, with each enemy’s spawnable address inassetand its place inxandy. 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.
4. Follow the player with the camera
Section titled “4. Follow the player with the camera”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.
5. Add a backdrop with depth
Section titled “5. Add a backdrop with depth”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.
6. Write the rules
Section titled “6. Write the rules”-
Aim. Keep
aimUp(fromup) andmoveX(frommove), and ask the player’sfacing. One formula gives the direction: ahead, straight up, or diagonal while running. -
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°. -
Checkpoints. Touching a flag (an Arcade Sensor) raises
checkX. After a lost life, callreseton the player with"x,y,z"at the checkpoint: its home moves there, and every later reset returns to it. -
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.
-
The end. Out of lives, or the core broken, ends the game and keeps the best score.
7. Build and play
Section titled “7. Build and play”-
Press Build Cartridge and publish the game with its four spawnables (Publish and share).
-
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.
Limits
Section titled “Limits”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.
What you learned
Section titled “What you learned”arcade.plane = xymakes 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.