Health, enemies and combat
Health and hazards
Section titled “Health and hazards”Add a Health to anything that can be hurt and set its Max. After a hit it flashes white and blinks, and can’t be hurt again for its Invincible Time; at zero it dies, sends its Death Message (say PlayerDied) and is destroyed (untick Destroy On Death to play a death animation first). Add a DamageOnTouch to whatever hurts: spikes and lava (it keeps hurting while you stand in it), enemies, bullets. Its Layers says who it hurts (Player on spikes, Enemy on the player’s bullets; empty hurts anything with health), Knockback pushes the target away, and Destroy On Hit spends a bullet. A collider on a child entity counts for the nearest Health above it, so a sword or a hurtbox can be its own child, and it never hurts its owner. Nor does it hurt its own team: with a Team (or a turn taker’s, a strategy unit’s) on both, allies pass over each other, and a shot is on its shooter’s team (see Teams). The Arcade template’s ship has three hearts, and its enemies and bullets use both.
Moving platforms
Section titled “Moving platforms”Add a Mover to a platform (or a saw, a lift, a gate) and give it Points to visit, as offsets from where it’s placed: 4 0 goes four units right and back, 0 6 is a lift, 4 0; 4 3; 0 3 goes round a square. It moves at Speed, waits Wait seconds at each point and eases in and out of them (untick Smooth for a steady saw). Mode is PingPong (there and back the same way), Loop (straight back to the start and round again) or Once (a door sliding open). Whatever stands on it rides along. Its Time is how far into its trip it is: give a row of platforms different times so they don’t move in step. Set its Beats and it steps from point to point on the music’s beat instead (see Keeping the beat). The Scene view draws each mover’s path; select it to drag its points, add more and take them off. Make a lift a one-way platform so players can walk through it at the bottom.
Enemies
Section titled “Enemies”A Patrol walks its body back and forth at Speed, turning at walls and, with Turn At Edges, before walking off a ledge. Give it a Left and a Right to keep it to a stretch of a long floor: it turns that far either side of where it’s placed (0 walks on until a wall or an edge). The Scene view draws its route, and you can drag its ends. Its Walked is how far along from where it was placed it is: the game keeps it up to date (knock it back and it walks back to its route), and setting it starts it part of the way along. A Chase goes after its Target (Player) once it’s within Range, and gives up once it’s Give Up further away than that. With Needs Sight it has to see the target first, past any walls; with gravity it runs left and right after it; without, it heads straight there, or finds its way around a tilemap’s walls if Around names it (Level). Stop Distance keeps it back, for an enemy that shoots. Give an entity both and it patrols until it spots you. Both flip the sprite to face where they’re going (draw it facing right). Add a DamageOnTouch and they hurt.
Grid enemies
Section titled “Grid enemies”Entity → Characters → Grid Enemy makes an enemy for a grid game: a Grid Movement a little slower than the player’s (its Step Time), a Grid Chase, and an enemy Attack whose Hitbox child hurts the Player layer. A Grid Chase steps after its Target (Player) once it’s within Range, tile by tile and the shortest way round walls, solid things and other grid movers (it waits behind one blocking a corridor), and gives up once the target is Give Up further away than that; with Needs Sight it has to see the target first. It stops Stop Distance steps away (1 is next to it, 2 keeps a cell between them) and turns to face it, so an attack swings its way. At 0 it walks into its target’s cell, and if the target is solid it bumps into it each step instead: a roguelike’s bump attack (its Bumped event and Bump Sound). A Grid Patrol walks a grid mover round its Points, in cells from where it’s placed (4 0, or 4 0; 4 -3; 0 -3 round a square), finding its way round walls between them, waiting for whatever stands in its way and pausing Wait seconds at each. Its Mode goes there and back, round in a loop or once, like a Mover’s; switches start and stop it (Running), Leg starts it part of the way round, and the Scene view draws its route; select it to drag its points from cell to cell, add more and take them off. Give an entity both and it patrols until it spots you, then finds its way back to its route once it gives up. Either one steps on its own, never with the player’s keys; in a network game the host moves it, after the nearest player. For a roguelike’s fighting, give grid movers a Bump Attack: stepping into something with Health on its Layers (Enemy) hurts it by Damage instead of bumping, with a lunge toward it and back over a step’s time, its Sound, an Effect prefab on what it hits and an optional Hit Stop; holding the way keeps hitting until it falls, and then the way is clear. On the player it attacks the monsters it walks into; on a monster whose Grid Chase has Stop Distance 0 (with Layers Player), it attacks the player it walks into. Taking turns, each hit is an action, so a hit and the monster’s hit back go turn by turn. Give the things it hits an Invincible Time of 0 so each hit lands. Scripts hear its Hit event; in a network game the host does the damage.
Swords and close-up attacks
Section titled “Swords and close-up attacks”Select the player and choose Entity → Characters → Add Attack: it gets an Attack and a Hitbox child to its right, a trigger on the Attack layer with a DamageOnTouch that hurts enemies. Pressing the Attack action (X, L, the right mouse button or the gamepad’s X) winds up for Windup seconds, brings the hitbox out for Active Time seconds (it’s hidden the rest of the time), then rests for Cooldown; a press meanwhile swings as soon as it can. Each swing hurts each thing once, however long it lingers on it, and a hit freezes the game for Hit Stop seconds so it lands hard. The hitbox swings the way its owner faces (laid out facing right, it’s mirrored to face left, and turned up and down in a top-down game). Lunge steps forward as it strikes, a Sound plays, and an Animation with an Attack clip (AttackUp and AttackDown too, top-down) plays it. An enemy’s attack has no Action: it swings at its Target (Player) once it’s within Range, turning to face it first, so a knight is a Patrol, a Chase and an Attack with a hitbox that hurts the Player layer. For hits that follow the animation frame by frame (the fist out on two frames of a punch, a head that takes more), leave its Hitbox empty and give the entity a Hitboxes instead: see below.
Turrets and guns
Section titled “Turrets and guns”A Shooter fires its Prefab (Bullet, which needs a Body) every Interval seconds at Speed: at its Target while it’s within Range, or in its Direction. Count and Spread fire a fan of shots (or with one shot, wobble its aim), Offset is where shots appear, and a Sound plays with each volley. Set its Action to Fire and it’s the player’s gun instead: it fires while Fire is held, towards the right stick or the mouse. Shots are turned to face the way they fly. Set its Beats to fire on the music’s beat instead of every Interval (see Keeping the beat).
Checkpoints
Section titled “Checkpoints”Tick a player’s Health’s Respawn and losing its hit points doesn’t destroy it: it disappears for Respawn Delay seconds, then comes back with full health (and a moment of invincibility) at the last Checkpoint it touched, or where it started. A checkpoint is a trigger with a Checkpoint: touching it makes it the Active one, turns its sprite its Active Tint, plays its Sound and sends its Message. Bottomless pits and lava are a DamageOnTouch with Kill ticked, which kills straight through invincibility. Cameras following the player jump straight to where it comes back.
Hitboxes on animation frames
Section titled “Hitboxes on animation frames”A Hitboxes puts hitboxes and hurtboxes on each frame of an entity’s animation, drawn over the frames in the Clip Editor (Art → Animation Clips): while the entity shows a frame, that frame’s hitboxes hit other entities’ hurtboxes (and, on its Layers, the colliders of things with a Health), once per group a swing, with each hitbox’s damage, knockback and hitstun and each hurtbox’s multiplier. The Health takes the damage (nothing lands during its Invincible Time), the Body flies off, and Game → Show Hitboxes draws the boxes as the game plays. With an Attack whose Hitbox is empty, the Attack action plays its Attack clip from the start each swing and that clip’s frames do the hitting. It’s all in Fighting games.