Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

Player

<CharacterSpawn> spawns the player’s character inside a Landscape and draws it. WASD and the arrows walk it in the camera’s frame; the on-screen stick steers the same way. While the camera’s lock is on or the camera’s eye is in the character’s head, the character faces the way the camera looks and the keys walk it sideways and back without turning it, as Roblox’s shift lock does; the camera page says when. It runs at 5 m/s unless its movement says otherwise. Game listens to the keys, not <CharacterSpawn>, so a <CharacterSpawn> that remounts while a key is down, as one inside a <Landscape key={round}> does on a new match, walks on.

A walk walkTo starts, as a click on the ground does, shows a mark on the ground at the point asked for until the character arrives or the player takes over. By default it is the pulse, a flash with waves running out and a beam that flares. marker picks a pulsing ring, a sigil, motes of light that land with a snap, or nothing: it takes a GroundMark, the same shapes Targeting draws under a target. In a room the walk goes to the room too, which finds the character’s path on its own navmesh, baked from the same map, and starts the character on it at the step the player’s page did.

localPlayerRing draws a soft ring on the floor under the local player’s own character, never under another player’s or an NPC’s, so the player finds their character among look-alikes from a far camera. localPlayerRing draws the engine’s white ring, and options set its radius, width, color and opacity, as LocalPlayerRingOptions lists them. The ring tilts to the floor the character stands on and keeps that floor’s height through a jump. It draws only while the character’s body shows, so a body still loading has no ring. It is off by default: Dota 2 rings the player’s own hero in white, Overcooked 2 and Moving Out ring every cook in its player’s colour, and Roblox, Unity, Unreal and Godot ship only decals to build one from.

An avatar is a VrmBody: the URL of a VRM file, its scale, the armSpread that holds its arms off its body, and, for a body with cloth, the armColliders that keep that cloth off its arms. The engine turns a VRM 1.0 body, whose front faces +z as glTF’s does, so that it faces the way it walks, and leaves a VRM 0.x body, which already faces -z, as it is. rotateY, in radians, turns a body further, for a file that faces some other way. avatar takes the name registerAvatar registered a body under, never the body itself, since only a name travels to every page, as the sample registers one.

A body’s simplified draws lighter copies of its skinned meshes in their place, each made on a worker once a file within about a centimetre of their outline, and each off by default:

  • sunShadow: true casts the engine sun’s cascades from a copy. Every other shadow, such as a lantern’s, draws what the view draws.
  • far: true draws a copy in every pass while the body stands far from the camera: where a centimetre spans under a pixel of a 1080 pixel tall screen, past about 12 m under a 50 degree lens. The switch keeps a band either side, so a body at the line does not flicker. Each camera keeps its own band, so a screenshot never moves the view’s choice.

These copies are the body’s detail levels, as Unity’s LOD Group, Unreal’s skeletal mesh levels and Godot’s generated levels draw them; here the engine makes each from the body’s file. A copy that would keep half a mesh’s triangles or more is not made, and a mesh with a cut-out, a see-through material or morph targets keeps itself. Last Light’s woodsman, at 59,716 triangles, casts from 12,610 and draws 13,358 far off.

A character’s head and eyes watch the player’s camera, so a character met reads as looking at the player. The head takes a share of the gaze within a limit, and characterMotion.headTurn holds the numbers.

A body’s headTurn sets its own numbers over those. With headTurn: { followLook: true }, the character the camera follows, on the page that steers it, watches where its player looks, and a point aimAt set wins. Its spine then takes a tenth of the gaze’s yaw first, so the head leads and the chest follows a little, as Unity’s look-at weighs the body under the head. It is off by default, as in Unity’s, Unreal’s and Godot’s third-person templates.

The engine ships no VRM body, so a game imports one by name from @spawnite/assets/avatars, such as import { fris } from "@spawnite/assets/avatars", or its own file with ?url. spawnite model avatar turns a character rigged by Meshy or Mixamo into a VRM body, as Models says. A body from @spawnite/assets takes the rest of its record from @spawnite/assets/avatars.json, keyed by the file’s name, as the mmorpg’s avatars table and the arena’s registration do.

In a room, the engine draws every character from the room’s stream, the local player’s own included, unless Game sets replicas={false}. A scene places <Replicas> to add an overlay, taking over the engine’s draw while mounted.

What the character wears is its appearance: its avatar, model, and primitive’s shape and colour, which travel to every page as names, so a page that joins late draws what the player’s own page draws. A page draws the first of them it can: an avatar it registered, else a model it registered, else the primitive. A name a page never registered warns once in development. Two characters in one avatar are two copies of it: the page parses the file once for each body it draws at once, and downloads it once. Roblox draws every player from the HumanoidDescription its server applies in the same way.

The character’s appearance comes whole from one place, so no part of a losing one leaks in:

  1. spawnCharacter’s props, where they name any of it, such as a class’s model.
  2. Else the scene’s <CharacterSpawn>, where it names any of it.
  3. Else the avatar the player brings, the one the player’s join names, avatar in Game’s room options.

So the game’s look wins wherever the game sets it, and the player’s own avatar fills in where it sets none. The look the game names is the one control, in three modes:

The game wants It writes
Its own look only, never the player’s a look on <CharacterSpawn>, or one per pick in spawnCharacter’s props
The player’s own avatar always no look: a player who brings none wears the default capsule
The player’s own avatar, else its own look a look with playerAvatar, which puts the avatar the player brings over its model

Roblox dresses each player in their own avatar unless a StarterCharacter replaces it, which is one switch for the whole game. Here the mode goes on the look, so a lobby can show players’ own avatars while a match dresses them in the game’s. A page that never registered the avatar a player brings draws the look’s model under it, or its primitive. A look that is only an avatar keeps nothing under the player’s avatar, so there such a page draws the default capsule.

packages/engine/test/outside/PlayerAvatars.tsx
import { CharacterSpawn } from "@spawnite/engine";
/** The game's look for everyone: each player wears the knight, whatever
* avatar the player brings. */
export function KnightsOnly() {
return <CharacterSpawn model="knight" />;
}
/** Players' own avatars: the scene names no look, so each player wears the
* avatar the player brings, and one who brings none
* the default capsule. */
export function OwnAvatars() {
return <CharacterSpawn />;
}
/** Players' own avatars, named as the look's source: each player wears the
* avatar the player brings, and one who brings none the knight. */
export function OwnAvatarsOrKnight() {
return <CharacterSpawn model="knight" playerAvatar />;
}

spawnCharacter’s props take playerAvatar too, for one character’s spawn. A set of looks a player picks from, such as classes, is a look per pick in spawnCharacter’s props, as Changing the character’s look says.

A page poses the body of another player’s character every frame while it stands large on its screen, every other frame once it spans under 5 % of its height, and not at all while it is out of its view. Its clips play on while it is out of view, and its springs rest as it comes back, so it walks in mid-stride with its hair at rest. Nothing a game decides reads another character’s pose, since a shot meets its capsule. The character the page steers is posed every frame, on screen or off, because a game may aim its shots from its hands. cullingMode on an Npc or a CharacterView sets it for one body: AnimationCulling.AlwaysAnimate, or AnimationCulling.CullUpdateTransforms, the default for every other character. The names are those of Unity’s Animator.cullingMode. Roblox throttles the animation of a character small on screen by default in the same way, and leaves the player’s own character alone.

A raycast, a pointer event’s included, meets an avatar as an invisible capsule the size of its physics body rather than its skinned model, so it costs no more over it than over any other mesh. A model or a primitive the character wears is met on its own meshes.

Its props are in CharacterSpawnProps.

The three body fields, radius, height and collisionMask, are the character’s at spawn: the physics cuts its capsule to them. What it steps over, climbs and jumps is the character controller’s, controller, a partial CharacterControllerTrait laid over its defaults. Among them are stepHeight 0.6 m, maxSlopeRadians 50 degrees, floorSnapDistance 0.6 m and jumpHeight 1.2 m among them. pushes lists the layers of the dynamic bodies it shoves as it walks into them, every layer when left out. turnWithPlatform, off by default, turns its facing with a turning platform it stands on, though it does not carry it round the platform’s axis. maxSlopeRadians is its one walkable angle: it climbs, stands on and walks down any ground up to it, and slides down anything steeper. Unreal’s walkable floor angle, Unity’s slope limit and Godot’s floor max angle work the same way, each 45 degrees or near it by default.

For a side-scroller, controller={{ plane: Plane2D.Side }} keeps the character on x and y, and the movement’s dropThroughInput picks what drops it through a one-way platform, as Side-scrollers says.

A game whose ground rises steeper than the default sets controller={{ maxSlopeRadians }}, the way Unity’s CharacterController and Godot’s CharacterBody3D carry their slope limit on the character. Past a ledge’s edge the character stands on its rim while the ground under its centre is walkable or lies farther below its feet than its height. Over a bank steeper than maxSlopeRadians within that reach, it slides.

The controller walks the character’s capsule itself, as Unreal’s CharacterMovementComponent does, behind one call, moveCharacter(step, character, { velocity, jump }), which its movement makes once a tick. The call is a move along the floor it found under it, one slide along a wall, a step onto what stands under stepHeight, and a push back out of any walker the move left it inside, cast like the move, so a wall or a ball in the way stops it. Each cast stops it 1 cm off a box or a rock’s hull, at a corner too, where Rapier’s own cast lets its dome come up to 6 mm nearer a corner. Two walkers that meet head-on stay a body’s width apart, unless a wall pins one inside the other.

The character’s TransformTrait is where its capsule stands: the dump and the stream carry it, and a room’s correction rebuilds its capsule on it, in the room and on every client alike. Its model’s feet are drawn apart from it, by its DrawnFeetTrait trait, which the view reads. On a slope the capsule rests above the ground under its axis, and its feet are drawn on that ground, no farther than its stepHeight under the capsule and no farther than the slope it rests on lifts a capsule, plus 5 cm. Over a ledge’s rim, where the face it rests on is the ledge’s level top, its feet stay within those 5 cm of the capsule’s bottom, so it stands on the rock rather than in it. The stream carries no drawn feet, and a room measures none, since it draws nothing.

Each client casts its own rays against the same ground, so every tab that shows the character large draws its feet at the same height. A client casts them for another walker from when it spans 3 % of its screen’s height until it spans under 2.5 %, and for six steps after, while its feet ease from the measured ground back to its TransformTrait, the capsule’s bottom. A smaller walker, or one out of view, is drawn at its TransformTrait and casts nothing once its feet have eased there. Its feet ease onto the measured ground over the same six steps as it grows past 3 %, so none jumps as it crosses a line. Unreal’s CharacterMovementComponent and Unity’s CharacterController work the same way: the capsule is the truth, and a separate pass places the mesh’s feet without moving the capsule.

Another walker’s capsule is ground like any other face: the character lands on a monster or on another player that blocks it, walks on it and jumps from it as from the ground. A jump from a walker’s top lifts its feet jumpHeight above it, and its movement drops a press in the air past its coyoteSeconds, so it never climbs walkers in the air. A capsule’s top is a dome, and where the character holds on it follows its maxSlopeRadians. A default body holds anywhere the dome is within 50 degrees of level, up to about 0.5 m off the walker’s axis for two default capsules, and a landing further out slides it off its side.

On a walker the character’s feet are drawn on its top, and every tab draws them at the same height while it moves. The character stands on the middle walker of a stack three high with a 1 cm gap. A room and each of its clients stand it at the same height on a walker that stands still. A walker that walks carries the character by its own move in the same tick, since the room moves each walker no player controls before the players’ characters and a base before its rider. Fortnite and Roblox let players stand on heads the same way. Unreal lets a pawn stand on another unless the base refuses it, and Zelda slides the player off an enemy.

How the character runs, stops and turns lives on its MovementTrait trait: its speed, acceleration, deceleration, turnRate at speed, airControl and coyoteSeconds. turnInPlace turns it on the spot from a stand, past turnAngleRadians, 60 degrees, at standTurnRate and for at most maxTurnSeconds. How high it jumps is the controller’s jumpHeight. airControl multiplies its acceleration and deceleration while it is off the floor, and below 1 its body faces where it moves there. 1, the default, steers it in the air as on the ground, 0 keeps the velocity it left the floor with, and above 1 steers it faster. characters() refuses one below 0, which would push it away from the stick, or one that is not finite, as the world is made. Unreal’s character defaults to 0.05; a platformer that wants committed jumps sets a low one.

coyoteSeconds is how long after the character walks off a ledge a jump still launches, 0 by default, as in every engine; a platformer sets about 0.1, or adds the platformer kit, which keeps its own. preset picks a whole record. Responsive, the default, brings it to full speed in a tenth of a second and pivots it at speed. Realistic takes a third of a second to reach speed and to stop, and plants its feet to turn on the spot before the character walks off. movement lays single settings over the preset: movement={{ speed: 7 }}. The devtools inspector shows the character’s settings on its row, each number as a slider, the turn’s angle in degrees and turnInPlace as a switch, and an edit moves it at once. Once a number feels right, the card’s Copy as prop button copies the changed settings as movement={{ speed: 7 }}, ready to paste into <CharacterSpawn>.

Every player’s character starts from one chain of settings, each link laid over the last. The links are the engine’s defaults, then the game’s characters({ movement, controller, capsule }), then the scene’s <CharacterSpawn> props, then the props a spawnCharacter call gives. The player’s save restores over all of them. A preset on the <CharacterSpawn> or in a spawnCharacter call replaces the movement record below it before its movement lays single settings on it. So a game that wants every player a little faster in every scene writes characters({ movement: { speed: 6 } }) once, and a scene that wants its own feel names it on its <CharacterSpawn>.

In a room the character moves as it does alone. A scene holds one <CharacterSpawn>, and with the game’s characters() it is where a room reads its players’ characters from. The room mounts the scene, and its <CharacterSpawn> spawns nobody there. The room spawns every player’s character with the chain above: the <CharacterSpawn>‘s preset, movement, body fields and controller over characters()’ settings. It adds the <CharacterSpawn>’s facing, health, stats and respawn, and hands each plugin’s character hook the rest of its props, such as bagSlots, weapons, abilities and resources, all as they stood when the room started.

respawn says whether the character comes back once its health runs out, after how long and where, as the health page says. Where the scene places no spawn points, a character spawns at <CharacterSpawn>’s position, as it does alone, unless another character stands within a metre of it, as Unreal’s GameMode skips an occupied PlayerStart.

The room refuses a scene’s file that exports movement, so a game sets its characters’ movement in characters() or on <CharacterSpawn>. Each client reads the character’s settings from the stream. The inspector shows them on its row read-only, greyed with the reason, unless the room takes edits. A room takes edits only when startRoom is given allowEdits: true or the room’s process runs with ROOM_EDITS=1, as the arena’s spawnite.room sets, so no client sets its own speed in a game others play.

Where it does, a slider edit on your own character goes to the room as any devtools edit does, and the room clamps it to the slider’s range and streams it to every client; the devtools page says how. On a room’s world the character’s row holds the room’s settings as they stood when the player joined, so an edited card reads “Tried, not saved” and Copy as prop copies the fields that differ from the room’s. To keep them, paste them into <CharacterSpawn>’s movement.

A scene places spawn points with <SpawnPoints points={[[0, 0, 4], [2, 0, 4]]} />. In code, call placeSpawnPoints(writer, points) with Vector3s and the setup writer from a plugin’s setup or a logic component’s useSetupEffect.

The room stands each joining character at one of the points, with <CharacterSpawn>’s other fields unchanged. Each player holds the lowest free seat number, released when the player leaves or the character is gone.

The player in seat n spawns at point n, or at the next point no other character stands on. With every point taken, the player takes the nearest free place round point n, as Many players at one point says. The character’s first step stands it on the first thing under the point, such as a floor, a voxel grid’s top or the terrain, as an NPC’s does.

In a game with teams, <SpawnPoints team={red} points={...} /> or placeSpawnPoints(writer, points, { team: red }) places points for one team, as Roblox’s SpawnLocation.TeamColor does.

Under a <Match>, <SpawnPoints> places points the match owns, in its Entity’s frame, so two courts’ sand points never meet. <SpawnPoints exit> places where a member who leaves it stands. readSpawnPoints(world, { owner, team, exit }) reads a set back.

A character whose point another character already stands on takes the nearest free place round it, so a hundred players who join at one <CharacterSpawn> stand apart and walk off. The places lie on rings about 1.5 m apart for the default capsule, wider for a wider one. A place counts where no character stands within 0.3 m of the new one’s capsule. In a world with physics, it also needs a walkable floor and a way from the place inside it with no wall, no climb steeper than the character’s maxSlopeRadians and no drop off an edge. So the places keep to the platform or the clearing the point stands in. A side-scroller’s places lie along x on the point’s line, so its depth holds.

characters({ spawnRadius }) sets how far round the point the search goes: 12 m by default, about 200 places on open floor, as Roblox’s SpawnLocation.Size and Arma Reforger’s spawn radius set it. With every place taken, the character stands on a place another holds and the two push apart, as Collision layers says. spawnRadius: 0 stands every character on the point itself, as Roblox stacks characters on a full spawn. The search holds for placed points once every point is taken, a player’s respawn point and a respawn’s point. A position a game passes to spawnCharacter or teleport stands exactly where it says.

The character walks, jumps and aims on the six inputs characters() declares, which ride every tick’s input to the room, as any input a plugin declares does:

Input Kind Keys What it does
characters.inputs.move Vector W, A, S, D and the arrows Steers the character in the camera’s view, at most 1 long: up away from the camera.
characters.inputs.jump Button, edge: true Space Jumps the character, once for each press.
characters.inputs.heading Angle none The camera’s heading, which the move is read in; the camera sets it.
characters.inputs.pitch Angle none How far the camera looks above level, the character’s look while it strafes.
characters.inputs.strafe Button none Whether the character faces the heading as it walks; the camera’s lock sets it.
characters.inputs.aim Vector none The way the player aims the character on the ground, in world axes, as Aim and side-step says.

Code names each input by its handle, as the table does: a system reads one with readInput(character, characters.inputs.move). The input’s own name drops inputs, characters.move, and an error message prints that name. characters({ keys }) moves the move’s and the jump’s keys, and gives the aim keys of its own: characters({ keys: { jump: ["Space", "Enter"] } }) jumps on Enter too, and characters({ keys: { jump: [] } }) frees Space for a dodge. A game that lists no characters() binds W, A, S, D and Space to its own inputs.

On a phone, the engine draws a stick labelled Move for the move and a Jump button for the jump, while the player controls their character, as Touch controls says. The stick fills the same characters.inputs.move the player’s keys fill. characters({ touch }) changes them, each left out keeping its default:

  • touch: false draws neither, for a game whose own gestures walk the character.
  • touch: { jump: false } draws the stick alone. A jump with no keys draws no button unless touch names one.
  • touch: { move: { label }, jump: { label, icon } } relabels them.
  • touch: { aim: { label: "Aim" } } draws an aim stick in the bottom-right slot, for a twin-stick game. It draws none by default.

A scene moves, resizes or hides either with a bound Joystick or Tap, and hides both with <TouchControls hidden />.

Game binds the engine’s own keys to these actions, each a handle in engineActions that useAction hears:

Action Keys What it does
interact E Uses what the character stands near, whose prompt shows.
cameraLock Shift Turns the camera’s lock on or off.
menu Escape Opens or closes the play menu.
pushToTalk V Held, sends the player’s voice; with open mic, turns the microphone on or off.
textChat / Focuses the text chat’s input in a room and frees the cursor.
performanceStats F2 Steps the performance overlay through its levels.
forward, back, left, right W, S, A, D and the arrows Fly the devtools’ free camera; a game may bind them.
climbUp, climbDown E, Q Fly the devtools’ free camera up and down; a game may bind Q.

controls() in the game’s plugins moves or drops an engine action’s keys: controls({ keys: { cameraLock: [] } }) frees Shift for a sprint. As the world is made, every key a game’s plugin binds, for a held input, a press or a page action, is checked against these and against each other, and a clash throws naming both and the fix. The ability bar’s keys are its own prop, outside the check. Unity’s Input System and Godot’s Input Map bind actions to keys the same way; player rebinding and gamepads come later, as more sources for the same actions.

The engine reserves / for the text chat’s input in a game whose package.json names a room; a game played alone reserves no key for chat. controls({ keys: { textChat: ["Period"] } }) moves it, as Roblox’s ChatInputBarConfiguration.KeyboardKeyCode does.

A press of Space jumps the character, and so does a press of the Jump button the engine draws on a phone, as Keys says. It leaves the ground at the speed that lifts its feet by jumpHeight on its CharacterControllerTrait, 1.2 m by default, under the scene’s gravity, and the same gravity brings it down. Under the default 9.8 m/s² it leaves at 4.85 m/s and lands 0.99 s later; a game that raises it, with definePhysics({ gravity: [0, -20, 0] }) passed to <Game physics>, keeps the height and shortens the arc. Unity’s Starter Assets state the jump the same way, as a 1.2 m JumpHeight, and Roblox as Humanoid.JumpHeight.

  • One press is one jump. A held Space jumps once, as in Unity’s and Godot’s templates. Space on a focused button presses that button and does not jump the character.
  • In the devtools’ edit mode, Space pauses the world and does not jump the character.
  • The character jumps from the ground. movement: { coyoteSeconds } lets it jump for that long after it walks off an edge, which is called coyote time, and it is off by default.
  • A press in the air is dropped rather than kept for the character’s landing: the movement has no jump buffer. The platformer kit keeps one.
  • The stick steers the character in the air as on the ground, at the same speed, unless movement: { airControl } is below 1, and faster above it.
  • A jump that meets a ceiling stops rising there and falls from it, as in Unreal and Godot.
  • A jump launched in the air, as a movement of a game’s own may launch one, sets the character’s rising speed to the jump’s, whatever its fall.
  • The jump is an edge button, characters.inputs.jump: the step carries the press on the one tick it was made, so a test, the harness and a room jump the character as the keys do. The step takes the press off the input it reads, so holdInput(game, characters.inputs.jump, true) jumps the character once, on the next step. A press that reaches the room up to 17 ticks late still jumps the character, once, on the room’s next tick.

The character’s CharacterTrait says whether its last move ended with it on the ground, isGrounded, and the entity it stands on, standingOn. It holds how long it has been off the ground, airSeconds, the jumps moveCharacter launched since it left it, jumpsSinceGrounded, which a push’s lift does not count, and its vertical speed in metres a second, negative on the way down, verticalSpeed. moveCharacter writes it as it moves it, so a game and the dump read it off its entity, as Unity’s isGrounded and Godot’s is_on_floor() do. In a room, a correction puts the character’s body in the room’s state, in the air or on the ground, and the slope under it. A correction halfway through a jump leaves it the rest of the room’s arc, and one on a hillside walks it on up it as the room does.

On a VRM body the character plays three clips over the jump:

  • jump.vrma when the character leaves the ground standing, and run-jump.vrma when the character leaves it running. The one chosen as the character leaves holds until it lands, however the stick moves in the air.
  • land.vrma after the character lands with the stick idle, held for the clip’s whole length. A stick held on landing, or pushed during the crouch, goes straight to the run.

The land clip plays from the moment the character’s feet touch, 0.25 s in, because the frames before it carry a fall in its hips that the capsule has already made.

A player’s character at zero health comes back as CharacterSpawn’s respawn says: after a wait, where the character spawned, where it fell, or at a point the scene names. Where points are placed for the player’s team, a respawn at RespawnPlace.Spawn picks one of that team’s points as the character stands, so a switch of team moves the character’s next respawn too. RespawnOptions names the settings, and Health says how a character goes down and how a respawn at a point places the character.

setRespawnPoint(step, player, { position, facing }) sets where one player comes back, such as the last checkpoint the player’s character touched, and setRespawnPoint(step, player, null) clears it. position is where the character’s feet stand, so a pad’s top rather than its middle, and facing is radians about y. Left out, the character keeps its facing. readRespawnPoint(player) reads it back, or null, on the room and on the player’s own page. As Roblox’s Player.RespawnLocation, the point belongs to the player entity, not the character, so a new character keeps it.

The character’s next respawn stands the character on the point, over whatever place respawn names, and the next spawn does too, over the spawn points. respawn={false} still keeps the character down. A second player who comes back while another character stands on the point takes the nearest free place round it, as Many players at one point says. A character on the floor below, whose body does not reach the point, leaves it free.

A respawn passes over the point, and comes back as respawn says, in each of the following cases:

  • The player is on another team than the one the player was on when the point was set. A point set while the player had no team holds on every team. A switch back finds it again, as a Roblox SpawnLocation holds for its own team.
  • Another scene, or another world, is held than when it was set, or its world was wiped since.
  • The player plays in a match that places its own points, so a lobby’s checkpoint never pulls the player’s character off a court.

Where the game saves, characters.saves.respawnPoint keeps the point in the player’s game-wide record, so a rejoin restores it before the player’s character spawns. The player’s saved place still restores over it, so the character comes back where it left, as Minecraft and Valheim bring a player back where they logged out rather than to their bed. A point set on the player’s team is the exception: it stands over the player’s saved place unless characters() sets restorePlace, as that team’s points do. An obby that starts every visit on the last checkpoint turns the place off with saves: { position: false } on the game.

A point inside a wall stands the character there, as any respawn at a point does, and the world warns once. A point below the scene’s killBelowHeight is passed over for the character’s spawn, and the world warns once, unless characters({ outOfWorld: OutOfWorldEffect.None }) leaves falls to the game. The point is set on the room, from a system. The room’s tests step a player’s character onto two pads, take its health to zero, and read where and which way the character stands again:

packages/room/test/outside/Checkpoints.tsx
import {
defineBehaviour,
definePlugin,
defineSystem,
defineTrait,
Entity,
findCharacterPlayer,
Phase,
readEvents,
RunContext,
setRespawnPoint,
TransformTrait,
Trigger,
TriggerEnteredEvent,
useBehaviour,
Views,
type AuthoritativeStep,
type EntityProps,
} from "@spawnite/engine";
/** A checkpoint pad: the way the player's character faces as it comes
* back on the pad. */
export const CheckpointTrait = defineTrait("checkpoint", { facing: 0 });
const CheckpointBehaviour = defineBehaviour({
name: "checkpoint",
trait: CheckpointTrait,
runsOn: RunContext.Server,
description:
"Makes itself where a player's character comes back as it steps on the pad.",
});
// On the room, and in a game played alone: the last pad a player's
// character stepped on is where the character comes back. The
// player's save keeps it.
function touchCheckpoints(step: AuthoritativeStep) {
for (const { entity: pad, record } of readEvents(
step,
TriggerEnteredEvent,
)) {
const checkpoint = pad?.get(CheckpointTrait);
const top = pad?.get(TransformTrait)?.position;
if (!checkpoint || !top || !record.other) continue;
const player = findCharacterPlayer(step.world, record.other);
if (!player) continue;
setRespawnPoint(step, player, {
position: top,
facing: checkpoint.facing,
});
}
}
export const checkpoints = definePlugin(() => ({
name: "checkpoints",
systems: [
defineSystem({
name: "touch",
phase: Phase.Rules,
run: touchCheckpoints,
}),
],
}));
interface CheckpointProps extends Pick<EntityProps, "position"> {
/** Radians about y the character faces as it comes
* back on the pad. */
facing?: number;
}
function CheckpointRule({ facing = 0 }: Pick<CheckpointProps, "facing">) {
useBehaviour(CheckpointBehaviour, { facing });
return null;
}
/** A pad whose top stands at `position`: the point the character's
* feet come back to. */
export function Checkpoint({ position, facing }: CheckpointProps) {
return (
<Entity position={position}>
<Trigger radius={1.5} />
<CheckpointRule facing={facing} />
<Views>
<mesh position={[0, -0.1, 0]}>
<cylinderGeometry args={[1.5, 1.5, 0.2, 32]} />
<meshStandardMaterial color="#4fd18b" />
</mesh>
</Views>
</Entity>
);
}
/** Two stages of an obby, each with its pad. */
export function Stages() {
return (
<>
<Checkpoint position={[0, 0, -10]} />
<Checkpoint position={[0, 0, -30]} facing={Math.PI} />
</>
);
}

List checkpoints in the game’s plugins. touchCheckpoints reads TriggerEnteredEvent, as Trigger shows for a gate, and findCharacterPlayer finds the player whose character stepped on the pad.

Changing the character’s movement for a while

Section titled “Changing the character’s movement for a while”

Three calls change how the character moves from a game’s own predicted system, each predicted in a room and restored by a correction, as Change the character’s movement shows with a sprint, a dash and a blink, and a fourth, a launch, is the room’s:

  • addSpeedModifier(step, character, { key, more, seconds? }) multiplies the character’s top speed by 1 + more under a key defineSpeedModifier makes: a sprint, a crouch, a root at more: -1. Keys multiply with each other and with its moveSpeed stat, and readMoveSpeed(character) answers the result. characters.systems.countDown ends a timed one through countDownSpeedModifiers(step), which a game that replaces the plugin’s countdown calls from its own predicted system.
  • pushCharacter(step, character, { velocity, seconds, endSpeed?, priority? }) holds the character’s horizontal velocity for a while, with no turn toward the stick: a dash, a knockback. A velocity.y above 0 launches it as a jump does. readPush(character) reads the push it holds, its velocity and seconds left, or null, for a movement of a game’s own that honours it. endPush(step, character) ends it at once, as its seconds running out would, with its ground speed cut to its endSpeed, such as for a stun. A respawn at a point ends a push itself.
  • teleport(step, character, { position, rotation?, keepVelocity? }) places the character’s body and transform at a spot exactly, never short of it, keeping its velocity unless keepVelocity is false, and draws it there with no glide. Inside a wall there, it pushes it out by the shortest way, up to its radius; still inside, it answers isClear: false and marks it stuck, and its next move recovers it. A blink that stops at the first wall casts the character’s capsule first with castShape, as the blink sample does.
  • addLinearVelocity(step, character, velocity) shoves the character, on the room’s step alone: its upward part lifts it off the floor, as Unreal’s LaunchCharacter does, and its sideways part decays on the floor by its controller’s groundFriction.

Each of the first three takes the predicted system’s step. A knockback or a teleport the room starts, such as a trap’s, takes the room’s step inside if (step.authoritative). Unreal’s MaxWalkSpeed, root motion sources and TeleportTo, and Roblox’s WalkSpeed and PivotTo, do the same three jobs.

characters.systems.movement is the code that walks each player’s character, once a tick, in the physics phase before the physics step. It is predicted: the room runs it for every player, the player’s page for the player’s own character, and a correction runs it again. Each tick it does five things for each character:

  1. While the player’s stick rests, it steers the character along its click-to-walk path, and a push on the stick drops the path.
  2. It reads the player’s stick in the camera’s heading and ramps the character’s speed toward readMoveSpeed(character) at its acceleration and deceleration, times airControl in the air.
  3. It turns the character toward the stick at its turnRate, or on the spot from a stand, and faces its heading while it strafes. A push from pushCharacter holds its velocity instead, with no ramp and no turn.
  4. It launches a jump pressed on the floor, or within coyoteSeconds of leaving it, and drops a press anywhere else. The controller launches a jump wherever it is asked, in the air too, so when to jump is the movement’s rule alone.
  5. It calls moveCharacter once, with the character’s velocity and jump.

characters.systems.npcMovement does the same for every character no player controls, on the world that decides outcomes, a game played alone included, and runs first, so a player standing on an NPC rides its move. In a room that culls by interest, an NPC no page wants moves less often or not at all, as the NPC page says.

Settings change how fast the character runs and turns; code changes what the character does. When the settings above are not enough, such as for a dash on a key, a double jump or a glide, copy the movement’s code into your game:

Terminal window
spawnite add kit character-movement

It writes four files under src/kits/character-movement/, which your game owns and changes. The MCP’s add_kit writes the same files:

File What it holds
index.ts The characterMovement plugin, whose one system replaces the engine’s movement
movement.ts The pass over each player’s character, the jump’s check and moveCharacter
steer.ts The ramp, the turn, the turn on the spot, air control and a held push
path.ts Click-to-walk: the steer along the character’s path while the stick rests

movement.ts, steer.ts and path.ts are the engine’s own files, at your game’s engine release, so the copy moves the character exactly as the engine does until you change it. List it yourself: import characterMovement from ./kits/character-movement in src/game.ts, and put it in the game’s plugins beside characters(), anywhere in the list, since it takes the movement’s place wherever it stands. The kit’s index.ts, as the command writes it:

packages/templates/src/kits/character-movement/index.ts
// SPDX-License-Identifier: MIT-0
import { characters } from "@spawnite/engine/characters";
import { definePlugin, defineSystem, Phase } from "@spawnite/engine/core";
import { moveCharacters } from "./movement";
// The players' movement as the game's own copy, written by
// `spawnite add kit character-movement`. movement.ts, steer.ts and path.ts
// are the engine's characters plugin's files of the same names: change
// any of them. List the plugin beside characters() in the game's plugins:
// it takes the movement's place wherever it stands in the list.
/** Each player's character's movement, in place of the engine's: the
* character's steer from the player's input or click-to-walk path, its
* speed's ramp, its turn and its jump, then one `moveCharacter` call.
* It takes the place of `characters.systems.movement`, its slot and its
* anchors, so every other part of `characters()` stays: the spawn, the
* respawn, the inputs, the aim and the NPCs' movement. */
export const characterMovement = definePlugin(() => ({
name: "character-movement",
description:
"The players' character movement: the game's own copy of the engine's, in its place.",
systems: [
defineSystem({
name: "movement",
phase: Phase.Physics,
predicted: true,
replaces: characters.systems.movement,
description:
"Steers each player's character on its input, or along its path while that input is not steering, and moves it with moveCharacter: the game's copy of the engine's movement.",
run: moveCharacters,
}),
],
}));

The copy keeps what characters() does around the movement:

  • Settings. It reads the character’s MovementTrait and CharacterControllerTrait, so characters({ movement }) and <CharacterSpawn movement> still tune it.
  • The rest of the plugin. The character’s spawn, respawn, inputs and aim stay the engine’s, and so does the NPCs’ movement.
  • Predicted. Its system stays predicted, so a room and the player’s page run it as they ran the engine’s. The character’s CharacterTrait is predicted already, so a rule read off its jumpsSinceGrounded or airSeconds needs no state of its own. A field the copy adds and keeps across ticks goes in a trait declared predicted, as Predicting a mechanic says.
  • One call’s overrides. moveCharacter takes overrides for one call, such as { jumpHeight: 0.8 } for a lower second jump or { gravityScale: 2.5 } for a short hop.
  • Click-to-walk. The walk command still sets the character’s path, and the copy’s path.ts walks it.

The step lists it as character-movement.movement (replaces characters.movement), which spawnite simulate prints. Listed without characters(), the world refuses to be made, naming the missing plugin. An engine upgrade leaves the copy as it is: to take the engine’s later movement, add the kit again with --overwrite, which writes over your changes.

A game that never walks its players’ characters needs no copy: it writes omit: [characters.systems.movement] on defineGame, and every walk command is refused no-movement. Roblox ships its character controls the same way, as scripts a place copies into StarterPlayerScripts and changes, and Unity’s Starter Assets ship a third-person controller as a script the project owns. Unreal’s character movement is changed in a C++ subclass instead.

For a platformer, a second kit replaces the engine’s movement with one of its own: coyote time, a jump buffer, a jump cut short when the player lets go, and a run 20% faster.

Terminal window
spawnite add kit platformer-movement

It writes two files under src/kits/platformer-movement/: index.ts, the platformerMovement() plugin, and movement.ts, its system. List it as the movement kit is listed, plugins = [characters(), platformerMovement()], anywhere beside characters(). It takes the following settings, each left out keeping its default:

Setting Default What it does
coyoteSeconds 0.12 How long after the character runs off a ledge a jump still launches. It takes the place of movement: { coyoteSeconds }
jumpBufferSeconds 0.1 How long a press of jump waits while the character cannot jump, so a press just before it lands jumps on landing
releaseGravityScale 2.5 How much harder gravity pulls while the character rises with jump let go, so a tap jumps lower than a hold. 1 turns it off
speedScale 1.2 A multiple of the character’s top speed: 6 m/s at the defaults. Its speed modifiers and moveSpeed stat still apply

platformerMovement({ coyoteSeconds: 0.08, speedScale: 1 }) sets two of them, and a setting below 0 throws, naming it. The plugin records its settings as its options, which a room compares with each page’s, so a setting you add goes there too. The kit reads the character’s speed, acceleration, deceleration, turnRate and airControl, so characters({ movement }) still tunes its run. It faces the character where it runs, or along the camera’s heading while it strafes. On Plane2D.Side it runs on the move stick’s x alone and faces +x or -x, and a strafe keeps the facing it has. It leaves out the engine’s turn on the spot and its turn toward an aim point. It walks a click-to-walk path with followPath, from @spawnite/engine/characters.

Each tick, movement.ts does the following for each player’s character:

  1. It steers and turns the character, then reads its jump in readJump. A press waits in bufferedJumpSeconds and launches while it stands on a floor, or within coyoteSeconds of leaving one with no jump since, and is not downed.
  2. It calls moveCharacter(step, character, { velocity, jump, overrides }). overrides is { gravityScale } while the character rises from a jump with jump let go, and none otherwise. A lift from the floor, or a launch from addLinearVelocity after its jump, rises whole.

The kit keeps its state in PlatformerTrait, a predicted trait onCharacterSpawn adds: bufferedJumpSeconds, isJumpHeld and launchCountAtJump. The jump is an edge button, so isJumpHeld comes from the releases readInputChanges lists. A release in the press’s own tick counts as none, since no key is held under a tick. On a phone the Jump button stays held while the finger is down, so a finger lifted early cuts the jump short, as Space does.

A double jump is a change to readJump, as Unreal’s JumpMaxCount is a setting. It counts its air jumps in a field of PlatformerTrait, since jumpsSinceGrounded reads 0 after the character walks off a ledge as on the floor, and passes jumpHeight in overrides beside any gravityScale.

The scaffold page says what licence each kit carries. Celeste builds its coyote time, jump buffer and variable jump the same way, in the game’s own movement code, and none of the five engines builds them in.

The character’s capsule stands in characters.collisionLayers.players, and every other character’s in characters.collisionLayers.npcs, two of the collision layers every world numbers. The terrain, its edge walls and its scatter stand in CoreLayers.ground, and a body that names no layer in CoreLayers.default. collisionMask lists the layers its sweeps and contacts meet, as a body’s does, every layer when left out, or { except: [...] } for every layer but those; a layer left out never stops the character and never costs it a test.

A chaser leaves out both characters’ layers. Two colliders meet only when each one’s mask holds the other’s layer, so a game that wants its monsters to block the player’s character gives them { except: [characters.collisionLayers.npcs] }. A ghost that walks through everything but the floor meets [CoreLayers.ground], the way Unity’s layer collision matrix and Godot’s collision mask narrow what a body meets.

Players’ characters block one another by default. characters({ collidesWithCharacters: false }) leaves the players’ layer out of every player’s capsule’s mask, so players walk through each other, as most Roblox obbies let them, while NPCs and the world still block them. A collisionMask on the <CharacterSpawn> or in a spawnCharacter call’s props wins over it. The setting is only the default for players’ characters: every other character meets what its own capsule’s mask names. A ghost the players walk through, while the players still block one another, leaves the players’ layer out of its own capsule:

packages/engine/test/outside/ghosts.ts
import type { Entity } from "@spawnite/engine/core";
import type { Vector3 } from "three";
import {
CharacterCapsuleTrait,
createTransform,
spawn,
TransformTrait,
VelocityTrait,
type Authority,
} from "@spawnite/engine/core";
import { characters } from "@spawnite/engine/characters";
// A ghost the players walk through, while the players still block one
// another: the ghost's own capsule leaves out the players' layer.
export const plugins = [characters()];
/** What a ghost's capsule meets: every layer but the players'. A pair
* touches only when each mask holds the other's layer, so neither a
* player nor the ghost stops the other. */
const ghostCollisionMask = { except: [characters.collisionLayers.players] };
/** Spawns a ghost standing at `position`, which the characters' movement
* moves by its velocity like any other character. */
export function spawnGhost(authority: Authority, position: Vector3): Entity {
return spawn(authority, {
traits: [
TransformTrait(createTransform({ position })),
VelocityTrait,
CharacterCapsuleTrait({ collisionMask: ghostCollisionMask }),
],
});
}

Two characters that block each other but stand inside each other, such as two a game teleports onto one point, move apart on their own. Each moves out at most the controller’s separationSpeed a second, 2 m/s by default, so two on one spot part in about 0.2 s, a nudge below the walk’s 5 m/s. controller={{ separationSpeed: 0 }} leaves a character inside another until one walks. Unreal caps the same move per frame as MaxDepenetrationWithPawn; a speed keeps it the same at any tick rate. A navmesh NPC never moves out of a player’s character, so the player’s character moves out alone.

A character walking its path, as an NPC, a click to walk or a bot does, that other characters hold still for the controller’s heldPassSeconds, 0.5 s by default, walks through characters until it stands inside none, and the push above parts them. Two crowds that meet in a gap one character wide get through rather than hold each other for good. A character the player’s input steers stays blocked. controller={{ heldPassSeconds: 0 }} keeps a held character held. Unity’s and Detour’s agents never block each other, and Unreal’s pawns always do.

A walker whose capsule starts inside a rock, a tree or a prop has no way out on foot: a save restored where the scatter now stands, or a spawn onto a placement, leaves the walker there. freeCharacter(world) stands the player’s character on the ground at the nearest spot within 10 metres where its capsule overlaps nothing, and it walks on from there. It answers whether it now stands clear. A character already clear stays where it is, and so does one with nowhere clear in reach, for whom it answers false. It moves the walker it is handed in place of the player’s character.

While the character’s capsule overlaps a hull or a prop, the step keeps the StuckTrait tag on the character, and takes it off once it stands clear. Another walker or a dynamic prop, such as a crate that fell on it, never counts, since it walks off either, and neither does a wall it walks into. A game shows its way out only while the character carries the tag, as the mmorpg’s Unstuck button does, the way Unreal’s OnCharacterStuckInGeometry tells a game when its character overlaps geometry it cannot leave. A dump lists it as stuck. It searches the ground alone, so a rock top is never where it stands the character. In a room the room’s next correction puts it back; the room frees no one yet.

Each of the following comes from a plugin the game lists, as What a plugin adds to a character describes: the character’s weapons from weapons(), its abilities from abilities(), its bag from inventory(), and the goods it carries from carrying(). Its resources need no plugin.

The character starts holding the weapons weapons names, by the names registerWeapon gives them, as the weapons a character holds says: in a room, a shot from any other is refused from the moment it spawns. Left out, it holds every registered weapon.

The character holds the abilities abilities names for as long as it is in the world, and has each resource resources names, such as ["mana"], where its settings say it starts, as the abilities page and the resources page say. Left out, it holds no ability of its own and has no resource.

In a game that lists inventory(), the character carries a bag of 16 slots, or as many as bagSlots says, and wears the engine’s equipment slots, as the inventory page describes. Roblox gives every character a Backpack and Minecraft every player an inventory; here a game that has no items lists no inventory(), and its characters carry none. The player’s save keeps both where the game’s save includes inventory, as Saving progress says, so a game’s save code never names them. A room gives the character the same bag and slots, empty each time the player joins.

In a game that lists carrying(), the character carries a stack of up to 10 goods, or as many as carryCapacity says. carryMix says what it may hold together, and carryPlacement moves where the stack draws, as the carrying page describes. The stack starts empty each time the player joins, because the world keeps custody of every good: what a character held when its player left is in the world’s recovery store.

<HeldItem> draws its children in the character’s right hand, so they move with the hand as its clips play. Put it in its overlay: <CharacterSpawn>’s children, or the Replicas overlay in a room, which draws every character the player’s page draws, the player’s own character included. On an avatar it hangs on the hand bone; on the default body it stands at its right side, at 0.6 of its height. position, rotation and scale place the held thing in the hand’s axes, which are the character’s while it stands at rest: y up, -z the way it faces and x to its right, so a barrel along -z points the way it faces. It draws nothing outside a character’s overlay. Roblox welds a tool’s handle to the right hand the same way, and Unity and Unreal attach it to a hand socket.

While it holds something, an avatar’s right hand closes round it: each frame, after its clip, the engine curls its thumb and fingers to a grip over whatever the clip does with its hand, and lets go when the HeldItem goes. The engine’s grip closes round a handle about 3 cm across that runs along the hand’s z axis, which on a VRoid body sits about [0.055, -0.025, 0] in the hand’s axes: put a sword’s or a wand’s handle there. grip sets how far each finger closes, from 0, straight, to 1, a fist, over the engine’s grip: grip={{ index: 0 }} points its index finger along the handle.

An avatar with no finger bones, and the default body, draw no grip. forward names the way the held thing’s tip points in its own axes, [0, 0, -1] unless set, which a cast’s hand turn carries onto the target as the spell releases: a wand whose orb is up its y gives [0, 1, 0]. Unreal lays a hand pose over any animation with a layered blend per bone, and Unity plays a grip clip on a layer masked to the hand. The engine’s grip is one curl per finger instead, as Unity’s humanoid muscles describe a finger, so the same numbers fit every avatar.

import { HeldItem, Replicas } from "@spawnite/engine";
export function Heroines() {
return (
<Replicas>
{() => (
<HeldItem position={[0, 0, -0.15]}>
<mesh>
<boxGeometry args={[0.05, 0.08, 0.45]} />
</mesh>
</HeldItem>
)}
</Replicas>
);
}

While the camera’s lock is on, or its eye is in the avatar’s head, an avatar aims where the camera looks. Its chest leans half the look’s pitch. While its right hand holds something, what HeldItem puts in it or a weapon the world registers, its right arm points along the look, so what it holds points at the crosshair’s line. An empty hand stays with its clip, as Valheim’s and Rust’s characters keep theirs down under the mouse. The arm follows the look to the camera’s stops: 80 degrees up or down, and 89 in first person. A step to the side turns its hips and legs toward it, as far as 75 degrees, while its chest stays square to the camera, and a step back plays the run clip in reverse with its legs facing the camera.

Where the characters’ clips include strafe clips, a step within 30 degrees of square plays strafeLeft or strafeRight with the character’s legs square, and a step back plays backpedal; each one missing falls back to the run. The engine ships none: a game adds one with registerClip(StrafeClip.Left, url), as Your own pose clips says. spawnite model clip writes a VRMA from a Meshy clip, as Models says. The pose eases in and out over about a quarter of a second as the lock turns on and off.

Unity and Unreal build the same thing from clips: an aim offset of upper-body poses and a blend of walk clips in eight directions. The platform ships neither, so the pose is built from the bones over whichever clip plays. Every page draws it for every character from its pose: the step writes whether the player’s input strafes and the pitch it aims at into pose.strafe and pose.pitch, and the room streams them. The player’s input itself stays on the room and the player’s own page. What the character holds points parallel to the camera’s look from its shoulder, so its line runs a few tenths of a metre beside the crosshair’s rather than meeting it.

aimAt(authority, character, point) aims a character at a point in the world as the game’s rule, such as a lock-on or the enemy a system just shot at. It works on any character: <CharacterSpawn>’s avatar or model, and an Npc drawn the same way. authority is the room’s step, a step of a game played alone, or findAuthority(writer, character) over a character only the page holds. While the character aims, the step turns it to face the point, and its steer walks it without turning it, as the camera’s lock does. Its legs turn toward its step, as far as 75 degrees off the point, and a step back plays its walk in reverse with its legs facing the point.

On an avatar its chest leans toward the point, and its right arm points at it while its hand holds something, as they do for the camera’s look. On a model, the whole model faces the point, and the bones under its spine, the hips and the legs, turn toward the step while the spine turns back. aimAt(authority, character, null) lets go, and the character turns back to the player’s aim or its step. Its legs ease in and out over about a quarter of a second, as for the lock. The point lives on the character’s AimPointTrait, { x, y, z, active }, so a room streams it to every page and the dump shows it. A point whose x, y or z is not a finite number throws, saying so.

// Excerpt of src/systems/shoot.ts
// In a system on the room, on each shot.
aimAt(step, character, { x: target.x, y: 1, z: target.z });
// Once nothing has fired for 0.5 s.
aimAt(step, character, null);

Unreal builds this from an aim offset, which poses the upper body toward the aim, and Lyra’s orientation warping, which turns the hips toward the step. Unity aims with a Multi-Aim Constraint from its Animation Rigging package, or with the Animator’s LookAt IK. Godot turns a bone toward a target with LookAtModifier3D. Roblox turns AutoRotate off on the Humanoid, and the game turns the Waist joint itself. Each of those leaves the game to wire the aim to the gameplay and to the network. aimAt and setPlayerAim are calls that the step, the stream and every page’s body read.

A twin-stick or top-down game aims the player’s character with the mouse or a stick, and the aim reaches the room as the character’s input, characters.inputs.aim, so the player’s page predicts the turn, the room decides it and every page draws it. The player aims it in three ways, the first that holds winning:

  • The aim keys and stick. characters({ keys: { aim }, touch: { aim: { label: "Aim" } } }) binds keys and draws a stick, read in the camera’s view as the move’s are. Neither is bound by default. A stick pushed less than 0.125 of its throw aims nowhere.
  • setInput(characters.inputs.aim, { x, y }), a direction in world axes: x is world +x and y is world -z.
  • setPlayerAim(writer, point) from a view, with the writer useViewWriter() gives it. Before each step the page writes the flat direction from the local player’s character to the point. null lets the aim go, and so do the view’s unmount, the window’s blur and a change of the player’s character, as at its destruction or a control transfer. A death leaves the request, since the same character stands again. The point under the mouse is Camera2D’s usePointerPlanePoint, fed to it each frame.

A game’s point wins over the player’s aim, and the player’s aim wins over the camera’s lock. A room’s lock-on reaches the player’s page one trip late, as one correction; a lock-on set from the page with setPlayerAim turns the character at once. Once the aim lets go, the character keeps facing where it faced. The player’s aim is flat, so the arm points level along it; a game’s point keeps its height.

isAiming(character) says whether a character aims, on any page, and readAimDirection(character, out) reads the flat direction, a game’s point first. Another page reads whether the player aims from the character’s pose.isAiming and the facing the room streams, since the player’s input stays on the room and the player’s own page. When the player’s input stops reaching the room for more than a quarter of a second, the room steps a still input: the character keeps its facing and stops aiming until the input returns.

A modal, a devtools camera and a live exclusive input context rest the aim, as they rest every input. So does a higher live context that takes the aim stick, such as a kart’s that lists a stick of its own, as Input contexts say: the seated character keeps its facing, and setPlayerAim’s request rests with the stick. characters comes from @spawnite/engine/characters; aimAt, isAiming and readAimDirection from @spawnite/engine/core; and setPlayerAim and useViewWriter from @spawnite/engine. A game declares inputs of its own, such as a lock-on button, in its own plugin. Unreal sends the controller’s control rotation with every move, and Unity’s Input System reads a twin-stick aim as a Vector2 action, as here; neither ranks a server’s lock-on over the player’s aim, which this room does.

With no avatar or model, the player’s character is a blue capsule cut to its height and radius, 1.4 metres tall and 0.35 metres in radius by default, standing on its position. It is drawn from geometry rather than a model file, so a game starts without any other game’s character and downloads no VRM or VRMA file. Hand it an avatar, a name registerAvatar registered, to wear a VRM body, and its body and clips start downloading as <CharacterSpawn> first renders.

shape swaps the capsule for another primitive and color paints it. A PlaceholderShape.Box is as tall as the character and as wide as its capsule; a PlaceholderShape.Sphere is a ball its radius round, resting on its feet. shape={PlaceholderShape.Sphere} color="red" makes it a red ball.

model names a model from the same registry Entity reads, so a model spawnite add asset registers works for the character too. Its clip names, clip speeds and material are its registration’s, so every page draws its model alike. The model stands with its lowest point on its feet, and its front, +z in the file as glTF puts it, faces the way it does. Where the file has clips, the character plays the ones its pose asks for: idle, walk and run blended by its ground speed, and jump off the ground, once, holding its last frame until it lands. The jump fades in and out over 0.2 s. A model with no clips stands as its file poses it. Each clip playClip asks of the character plays over them from its file, as an Entity’s model does. ModelClip names the four.

The blend places the idle at 0 and the walk and the run each at its stride speed: the ground speed at which the clip, played at its own pace, keeps the character’s feet planted. Between two neighbours the weights move linearly with the character’s speed. The walk and the run share one phase, so a blend of the two never crosses its legs, and the phase turns as fast as the ground passes under it, so the character’s feet hold on the ground at every speed. Below the walk’s stride speed the walk plays at its own pace and takes a larger share of the blend as the character speeds up; above the run’s, the run plays faster. A loop that holds its first pose before its first key, as a Meshy walk and run do for a frame, starts at that key, so the loop does not hitch.

The engine measures each stride speed when the character’s model loads: the mean speed at which each toe moves back under the hips while it stays planted, at the scale the model is drawn. It finds the toes, or the feet where the rig has no toes, by the names Meshy, Mixamo and VRoid give them, such as LeftToeBase, mixamorig:LeftFoot and J_Bip_L_Foot. Where it finds neither, or the clip moves neither foot, that clip plays at its own pace, the walk blending in at half the character’s top speed and the run at the character’s top speed. The model warns once in development, naming the model, the clip and the clipSpeeds to set. A missing clip leaves its place to its neighbour: a model with no walk blends from its idle straight into its run, and one with neither stands in its idle. A run that clips points at the walk’s clip, such as clips={{ run: "walk" }}, is one place in the blend, as with no run: the character walks at every speed past the walk’s.

Unity lays out the same blend as a 1D Blend Tree, whose Compute Thresholds → Speed reads each clip’s speed off its root motion, and Unreal and Godot as a BlendSpace1D, with Unreal’s sync groups keeping the walk and the run in step. Roblox’s Animate script plays one clip at a time and scales the walk’s rate by the character’s speed.

The registration’s clips points a pose at a clip the file names differently, such as registerModel("spirit", { path, clips: { run: "Sprint" } }) for a file whose run is called Sprint. A name the file lacks warns once in development, listing the file’s clips.

The registration’s clipSpeeds sets a stride speed in place of the one the engine measures, in metres a second at the scale the model is drawn, such as clipSpeeds: { walk: 0.7, run: 2.15 }. Set it where the measure reads a clip wrongly, such as a run whose feet slide, or where a clip warns that it cannot be measured. Each speed is a positive number, and the walk’s is below the run’s; anything else throws as registerModel runs, saying what to change. The walk’s speed stays below the run’s once the engine adds the speeds it measures and the defaults for a clip it cannot measure, so a run set below a measured walk throws as the character’s model loads, naming where each speed came from. ModelClipSpeeds is its type.

The registration’s material dresses the character’s model: a function handed each mesh’s own material, which returns the one it wears in its place, such as a glowing shader built over the file’s texture. It is read when the character’s model loads, so define it once outside any component. The material it returns is the game’s: the engine never disposes it, so one material can dress every mesh and every character. A function cannot travel to another page, and a name can, so a second look on the same file is a second registered name, such as registerModel("spirit-red", { path, material: red }).

characters({ view }) draws every character with a component of the game’s own, on every page, alone and in a room, for the local player, the other players and every NPC. The game lists that one characters() call among its plugins. The view takes CharacterViewProps: the character, and as children the overlay the scene’s <CharacterSpawn> or a placed <Replicas> hands it, called with { entity, height }. It draws where the character stands, since the engine places it. It may draw the engine’s CharacterView inside it to keep the engine’s body. Left out, the engine draws CharacterView itself. Unity’s player prefab, Unreal’s DefaultPawnClass and Roblox’s StarterCharacter are each this one setting of the game’s.

packages/engine/test/outside/BannerView.tsx
import {
Billboard,
CharacterView,
type CharacterViewProps,
} from "@spawnite/engine";
/** Every character in the engine's own body, with a banner over the
* character's head at the character's height that faces the camera from
* every side. Drawn where the character stands: the engine places the
* view. The game lists it once, as `characters({ view: BannerView })`
* among its plugins. */
export function BannerView({ entity, children }: CharacterViewProps) {
return (
<CharacterView entity={entity}>
{(drawn) => (
<>
<Billboard offset={[0, drawn.height + 0.3, 0]}>
<mesh name="banner">
<planeGeometry args={[0.6, 0.3]} />
<meshBasicMaterial color="gold" />
</mesh>
</Billboard>
{children?.(drawn)}
</>
)}
</CharacterView>
);
}

A prefab’s view still wins for a character spawned from it, and so does a view defineTraitView registered for a trait the character holds, so a view for one class is a registration. A model per class every page shares is its appearance, set as Changing the character’s look says; CharacterView’s appearance prop is a look this page alone derives, such as from its own settings. A look whose file never loads on one page gives way to the character’s next look there, and a view that throws draws its primitive; each warns once, and the character’s next look tries again. An NPC placed with <Npc> keeps its name over its head whatever the view draws, unless its nameplate is off.

setCharacterAppearance(step, character, { avatar, model, shape, color }) dresses a character in a new appearance, whole: each part it names goes on and each it leaves out comes off, so a model never draws under an avatar it wore before. Every page redraws it, and its old body stands until the new one has loaded, so the camera and its plate keep their hold. spawnCharacter with other props does the same through a new character, as Roblox’s LoadCharacter does, and setCharacterAppearance is Roblox’s ApplyDescription. It takes the room’s authority, so a pick a player makes on the player’s page travels as a command, and the room’s system finds the player’s character with findCharacter(world, player). A respawn stands that same character again, so the look it was given stays. A class that changes only its look is a setCharacterAppearance; one that also changes its stats or bag is a spawnCharacter with a name of its own, as the party sample does.

Whatever the character wears, its physics body stays the capsule the body fields cut. Its size never comes from its model, as a walker’s does: it is 1.4 m tall and 0.35 m in radius unless <CharacterSpawn> sets height or radius.

A body on glTF’s standard material shades from lit to the sky’s fill with its albedo’s own hue. Skin under the sun goes redder toward the edge of its light, where light scattered under the surface comes back out. An avatar’s subsurface gives its standard materials that falloff: each channel of each light wraps past the edge by wrap times the channel’s share of color, so a red colour lets red light reach furthest. It is off by default.

packages/engine/test/outside/Swimmer.ts
import { registerAvatar } from "@spawnite/engine";
/** The swimmer's body, whose skin reddens toward the edge of its light. */
export function registerSwimmer() {
return registerAvatar("swimmer", {
model: "assets/swimmer.vrm",
scale: 1,
armSpread: {
left: { out: 0, forward: 0 },
right: { out: 0, forward: 0 },
},
subsurface: {
color: "#ff3a20",
wrap: 1,
mask: "assets/swimmer-skin.png",
},
});
}
  • wrap runs from 0, Lambert’s falloff, to 1, light that reaches round to the back; 0.5 by default. The lit side keeps its value.
  • color is white by default, every channel alike, as Godot’s Lambert Wrap. A skin sets a red.
  • mask is an image whose red channel says where the falloff applies, on the body’s colour map’s UVs, such as skin white and cloth black. Left out, the whole body takes it.

A model a game dresses itself takes the same falloff from setSubsurface(material, options) on a MeshStandardMaterial or MeshPhysicalMaterial, inside the model’s material function. A second call moves the values in place.

Unreal’s Subsurface Profile, Unity HDRP’s diffusion profiles and Godot’s subsurf_scatter blur the lit screen, a full-screen pass every frame. This is the cheap form those engines also ship for a phone, as Unreal’s Preintegrated Skin and Godot’s Lambert Wrap are: a few instructions per light on the body’s pixels. It lights the direct lights alone. Under the WebGPU renderer a VRM avatar does not draw, as What stays off says, and a model’s material keeps Lambert’s falloff.

An avatar stands, runs, turns and jumps in the engine’s clips unless the game gives its own. registerClip under a pose’s name puts a VRMA file in place of that pose’s clip for every avatar in the game, such as a heavier run for a knight or a creature’s gait. Write registerClip(PoseState.Run, trot), with trot a ?url import of the file, as the one-shot sample imports its clip. Register it before the first character draws, beside the game’s other clips. The return forgets it: a character drawn after plays the engine’s clip again, and one already drawn keeps its clips until it draws again.

PoseState names the seven poses: idle, run, turnLeft, turnRight, jump, runJump and land. StrafeClip names the three strafe clips the engine ships none of. The engine’s land clip starts where its feet touch the ground, since the capsule has already fallen by then. A game’s land clip starts at its touch mark, registerClip(PoseState.Land, url, { marks: { touch: 0.25 } }), and plays whole without one. A room never loads a clip: every page plays the pose its room streams, with the clip its own game registered. A model character names its own clips with clips instead.

Roblox swaps the clips of its default Animate script by name, and Unity’s Animator Override Controller replaces a controller’s clips by name the same way. Unreal and Godot give each character its own animation blueprint or tree. Here one call per pose replaces the clip and keeps the engine’s blending, aiming and strafing over it.

playClip(character, name) plays a clip once over whatever the character’s pose plays, then fades back to the pose, as Unreal plays a montage. A cast or a hit plays this way. Every avatar plays its pose clips and each clip registerClip(name, url) names: a VRMA file, a ?url import, registered before the first character draws. A pose’s name, such as idle or strafeLeft, puts the clip in place of that pose’s, as Your own pose clips says.

import cast from "./animations/cast.vrma?url";
import { registerClip } from "@spawnite/engine";
registerClip("cast", cast, { marks: { release: 0.4, settle: 0.9 } });

marks names where things happen in the clip, in seconds from its start, as Unity’s animation events, Unreal’s notifies and Roblox’s keyframe markers sit on the clip: a VRMA carries no event track, so the marks sit beside its file. release is the frame a cast lets its spell go, and an ability that plays the clip casts at it. A look hears any mark with useClipMark(entity, "settle", heard), called on the page that draws the clip as the character’s one-shot crosses the mark, with the clip, the mark, its seconds and the play. That is where shards stand up as its hands come down, exact to the frame rather than to the room’s tick. Each mark raises the ClipMarkEvent event on the character for the step. spawnite play timeline shows a clip frame by frame with the second under each, which is how a mark is read, and Animations walks the whole path from a clip file to a confirmed mark.

The clip fades in over fadeSeconds, 0.15 s by default, and fades out over its last fadeSeconds. By default it plays over the character’s whole body. On an avatar, a run or a jump ends it early, faded out the same way, so it never slides across the ground in a cast. A model’s one-shot plays on through a run or a jump to its end, so a model that moves while it casts plays the cast on ClipLayer.UpperBody. { hold: true } holds the last frame instead, as a death does, until stopClip(character) fades it back, the next playClip replaces it, or it respawns. The call writes the OneShotClipTrait trait, which a room streams, so every page plays the clip on the character. A name the character’s clips lack plays nothing and stops the clip its layer plays, as stopClip does, and a dev world warns once with the names it has. Entity plays a model’s clips the same way.

layer: ClipLayer.UpperBody plays the clip on the bones from the character’s spine up, while its pose’s clip goes on driving its hips and legs, so it shoots or waves while it runs. A run or a jump does not end an upper-body clip. A clip on each layer plays at once, the upper body’s over the whole body’s, and stopClip(character, { layer: ClipLayer.UpperBody }) fades out the upper body’s alone. The engine finds the spine itself: a VRM avatar’s spine bone, and on a model the first bone whose name holds spine or abdomen, such as a Meshy rig’s Spine02, a Mixamo rig’s mixamorig:Spine or a Quaternius rig’s Abdomen. A model with no such bone plays the clip on its whole body, and a dev world warns once with the bones it has. The upper body’s clip writes the UpperBodyClipTrait trait, which a room streams as it does the whole body’s.

start, end and speed play part of a clip: from start seconds into the file’s clip to end, at speed times its pace. A held clip holds its end frame. Marks keep the seconds of the file’s clip, so a clip played from 0.3 s never raises a mark at 0.1 s. A start below 0, an end not after start, a speed of 0 or less, or any of them infinite throws, with what to pass. An end past the clip’s length plays to the clip’s end, and a dev world warns with that length. A gun that fires one shot of a looping burst clip plays its first shot on the arms alone:

// Excerpt of src/systems/shoot.ts
// In a system, on each shot.
playClip(character, "shoot", {
layer: ClipLayer.UpperBody,
start: 2 / 30,
end: 10 / 30,
speed: 1.5,
hold: true,
});
// When the aim lapses.
stopClip(character, { layer: ClipLayer.UpperBody });

Unreal plays a montage into a slot that a layered blend per bone limits to the spine’s branch, and sets a montage section’s start and its play rate. Unity plays the clip on an Animator layer with an AvatarMask that holds the upper body, and sets a state’s speed. On Roblox an animation track drives the joints its keyframes name, at a priority over the movement’s track, with AdjustSpeed and TimePosition. The engine names the layer, as Unity and Unreal do, and finds the spine for you, so the same call fits a VRM avatar, a Meshy rig and a Mixamo rig.

useAfterPose(entity, callback) calls callback({ root, bone }, seconds) on the page each frame, right after the engine has posed the entity’s model. It runs after its clips and one-shot clips, an avatar’s aim, grip and humanoid rig, and before an avatar’s springs, which follow what the callback moves. root is the model’s root object, and bone(name) is the bone of its skeleton named name, as the file names it, or undefined. Call it in any component under the Landscape, such as <CharacterSpawn>’s children. It works on <CharacterSpawn>’s model, a VRM avatar and an Entity’s animated model, and it stops when the component unmounts.

import { useAfterPose } from "@spawnite/engine";
import type { Entity } from "@spawnite/engine/core";
import { Quaternion, Vector3 } from "three";
const recoil = new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0), 0.2);
interface LeanProps {
character: Entity;
/** Radians the soldier leans back. */
lean: number;
}
export function Lean({ character, lean }: LeanProps) {
useAfterPose(character, ({ root, bone }) => {
root.rotation.x = -lean;
bone("RightHand")?.quaternion.multiply(recoil);
});
return null;
}

A bone that the callback reaches through bone goes back to its clip’s pose before the next frame, so a turn the callback adds each frame stays one turn, even over a held clip whose pose does not move. root keeps what the callback writes, so set its values rather than add to them. On a VRM avatar, bone reaches the raw bones, by the names its file gives them. Unity runs the same step in LateUpdate or OnAnimatorIK, after the Animator, and Unreal in a Control Rig or an animation blueprint’s post-process graph.

useFootsteps(entity, onStep) calls onStep({ foot, position, speed }) on the page each time one of the entity’s drawn feet lands. foot is HumanoidSocket.LeftFoot or HumanoidSocket.RightFoot, position is the point on the ground under the ankle, and speed is the metres per second the character crossed the ground at. Use it for what a step leaves: dust, a sound, a print. Call it in any component under the Landscape, such as <CharacterSpawn>’s children.

The engine reads each foot’s height off the posed body every frame, so it works for any clip, blend or turn the body plays, with no marker placed in a clip. A foot counts as lifted once it rises liftHeight over the lowest it stood in the last second, and lands as it comes back within plantHeight of it. A jump’s landing lands both feet at once. A body further than maxDistance from the camera is not read. The defaults are in FootstepsOptions. It reads a posed body, an avatar or a model with a rig. The placeholder, which plays no clip, steps nowhere, though it holds the feet as sockets as every humanoid body does.

packages/engine/test/outside/FootstepDust.tsx
import {
type Entity,
type ParticleEffect,
useFootsteps,
useParticles,
} from "@spawnite/engine";
export interface FootstepDustProps {
/** The character whose feet kick the dust. */
character: Entity;
/** The puff each footstep throws, one of the scene's
* `<Particles effects>`. */
dust: ParticleEffect;
}
/** A puff of dust where each of the character's feet lands, more of it at
* a run, and none for a turn on the spot. */
export function FootstepDust({ character, dust }: FootstepDustProps) {
const particles = useParticles();
useFootsteps(character, ({ position, speed }) => {
if (speed < 0.6) return;
particles.spawn(dust, { at: position, count: speed > 3.5 ? 10 : 6 });
});
return null;
}

Unity and Godot place footsteps by hand as events in each clip, Roblox as clip markers, and Unreal as anim notifies, or as sync markers generated from the feet’s height.

In a room, every page draws each other player’s name over their presence, the other player’s character in most games, and never the player’s own, and none for a player with no presence or a hidden one. The name is white, 12 px semibold, the same size on the screen at any distance, with a thin dark outline and a soft shadow and no box behind it, as Roblox draws a display name, so it reads on grass, fire and sky. Its bottom stands 0.15 m over the top of the character’s drawn body. While that player speaks in the room’s voice, as useSpeaking reads it, a green microphone stands left of the name: it shows within a tenth of a second of their voice and stays 0.3 s past their last word.

Who sees a name, and how far:

  • Anyone else: whole to 20 m, fading out to nothing at 30 m. A wall between the camera and the name hides it; the page checks each name’s line of sight five times a second, with the same ray a shot uses against cover.
  • A teammate, a character on the page’s player’s team: the name takes the team’s colour, never fades with distance unless the game sets fade or distance, and shows through walls, as Fortnite’s team nameplates and Roblox’s EnemyOcclusion do.

The plate hangs in the object the character’s view draws, as the interact prompt does, so a game that draws its own characters, as Holdfast does, gets it with no code. A player turns every plate off with Show other players’ names in Settings.

The scene’s <CharacterSpawn> sets how the plates look and when they show, with one prop, nameplate:

  • nameplate={false} draws no plates, for a game that draws names of its own.
  • nameplate={{ fade: [30, 50], size: 14 }} tunes the engine’s plate: how far it shows and where it starts to fade, where it stands over the head and its size in pixels. It also sets the colour of a name with no team, whether walls hide it for everyone, for enemies only or for nobody, and whose plates show. background: true puts each name on a 50% black pill. NameplateOptions holds each field and its default.
  • nameplate={MyPlate} draws each plate with a component of the game’s own. It receives NameplateProps: the character’s entity, the player’s name, whether the player is speaking, the color the player’s name draws in, whether the player is a teammate, and the setting’s size and background. The engine still places it, fades it and hides it behind walls. It draws in pixels, with the plate’s bottom middle at its origin. { component: MyPlate } does the same beside the other options.

The engine’s own plate is Nameplate, so a game’s plate can draw it beside something of its own, such as a health bar:

import {
CharacterSpawn,
Nameplate,
type NameplateProps,
} from "@spawnite/engine";
function PlateWithBar(props: NameplateProps) {
return (
<>
<Nameplate {...props} />
<mesh position={[0, -4, 0]} scale={[60, 4, 1]}>
<planeGeometry />
<meshBasicMaterial color="#ff4d5e" transparent />
</mesh>
</>
);
}
export function Run() {
return <CharacterSpawn nameplate={PlateWithBar} />;
}

A plate’s teammates and its colour come from teams: with teams() listed, two players on one team are teammates, and a plate wears its team’s colour, the color its defineTeam gives, unless the setting’s teamColors is TeamColorMode.Off. With no teams(), nobody is a teammate and every plate wears color, as Roblox’s Player.Team and its TeamColor drive its nameplates.

The name is the one the player joined the room as, PlayerTrait’s name on the player entity, which every page reads through useDisplayName on the player’s presence, where a DisplayNameTrait the game puts on it stands over it, as Entity says. A plate component receives both entity, the player’s presence, and player, the player’s entity.

What the other engines do: Roblox is the one that draws names by default, over every character, hidden behind walls, out to 100 studs, and a creator changes it with DisplayDistanceType, NameDisplayDistance and NameOcclusion. Fortnite’s island settings choose who sees nameplates, how far, whether obstacles hide them, and a voice indicator. Unity, Unreal, Godot and PlayCanvas give a game a billboard to build one from. This plate takes Roblox’s default and its look, Fortnite’s controls and its team default, and draws on the engine’s Billboard.

A player’s character is a character the player controls

Section titled “A player’s character is a character the player controls”

spawnCharacterBody(step, { position, facing }) spawns a character’s body, under the room’s step or a join’s step, as spawn takes them: the traits the step walks along a navmesh path, turns, jumps and poses, on the engine’s default movement. A player’s character is the same walker with ControlledTrait, which makes it an entity a player may control, and its health, body, bag and weapons, which the characters plugin spawns for the player. What walks, poses or draws the character reads the character’s traits, so walkTo(world, destination, character) sends a character with no ControlledTrait round the navmesh as it sends the player’s character. The engine draws a streamed character in its avatar as it draws a player’s character, unless Game sets replicas={false}.

In a game played alone, the engine draws a character a system spawned in the same view, so it shows alone as it shows in a room. ControlledTrait says a player may control the entity, and which one does: a chase, the Players collision layer and a room’s seats read it, and pass over a character without it. The devtools’ walkTo, which the CLI and the MCP call, is a test’s step on top of this one: it sends the player’s character and steps the world until the character arrives or its steps run out. Unreal splits it the same way: one Character walks, and a player’s controller or an AI controller possesses it.

walkTo returns what it did. A walk it started is { corners, partial }: the corners it walks, and partial, true where no route reaches the point and the corners stop at the nearest point the search reached, such as the foot of a rock the walkers cannot climb. The character walks a partial route and stops at its end. A walk it refused is { refusal }, a WalkRefusal:

Refusal When
NoNavMesh The world has no navmesh: it mounts no <Landscape>, whose ground every navmesh is baked from, or the bake has not finished.
NoCharacter None was named, and the world has no player’s character.
NotWalker The entity named is gone, or walks no path: it was spawned without spawnCharacterBody or spawnCharacter, so has no PathTrait.
StartOffMesh The character stands too far off the walkable ground to snap onto the mesh.
DestinationOffMesh The point is too far off the walkable ground to snap onto the mesh, such as a click into the sky.
NoRoute Both ends snapped and the search failed.

A refused walk changes nothing: the character keeps the path it had. A click into the sky leaves a walk under way alone, and a routine that wants its character stopped on a refusal clears the path itself, setTrait(step, character, PathTrait, { corners: [] }). A click on an interactable whose walk is refused forgets the interactable, so a walk under way presses nothing it passes. In a room, a walk the player’s page started goes to the room, which finds its own route; a walk the room’s navmesh refuses stands the character there, since the player’s page dropped the character’s last walk for it, and the room logs it.

Unity’s SetDestination returns a bool and its pathStatus says complete, partial or invalid; Unreal’s MoveToLocation returns Failed with a separate partial flag; Godot’s agent answers is_target_reachable(); Roblox’s path answers NoPath. None names why, and each walks a partial route to its nearest point, as this one does. A refused walk keeps the old path, as a Roblox walk goes on after a failed compute, where Unreal’s MoveToLocation aborts the old move: a refusal here is an answer with no side effect, so the caller chooses whether to stop.

<NavMeshModifier> inside an Entity marks a box that a route pays more to cross, such as a flower bed, a fence with no collider or a muddy patch. A walk walkTo starts, a click to walk, a carry guide’s path and a walker’s repath go round the box where a way round is cheaper, and through it where none is. The character controller never reads it, so a player still walks through by hand. The following garden marks a bed and a muddy patch:

packages/engine/test/outside/FlowerBed.tsx
import { Entity, NavMeshModifier } from "@spawnite/engine";
// A flower bed a route goes round and a player still walks through: a box
// 6 m long and 1.5 m wide on the ground, with no collider, and a muddy
// patch beside it a route crosses at three times the cost of grass.
export function Garden() {
return (
<>
<Entity position={[0, 0.5, 0]}>
<NavMeshModifier size={[6, 1, 1.5]} />
</Entity>
<Entity position={[0, 0.5, 4]} rotation={[0, Math.PI / 4, 0]}>
<NavMeshModifier size={[3, 1, 3]} cost={3} />
</Entity>
</>
);
}

A modifier takes the following props:

  • size: the box’s full extent along its entity’s x, y and z, centred on the entity, turned and scaled with it. Floors between its bottom and its top are marked, a floor level with its bottom face among them.
  • cost: how many metres of open ground each metre inside costs, 100 by default, at least 1, and a fraction such as 1.5 is fine. At 100 a route goes round wherever the way round is shorter than about a hundred times the way through. Infinity cuts the box out of the navmesh, so no route crosses it however far the way round, while a player still walks through: a stage or a bed nobody may trample. Where no way round exists, the route ends at the box’s edge, partial.
  • padding: metres the marked footprint grows on each side, the walker’s radius by default, so a route’s corners keep its capsule off the box. A gap between two padded boxes stays open when it is at least twice the radius and one cell wide, about 1.05 m. padding={0} marks the box alone, which suits a soft cost such as a lawn, so a route that only skirts it pays nothing.

Round a square box, the way is at most about twice the way across. So a cost of 2 or more keeps every route off a square, and a cost below 2, such as 1.5, lets a route cut across where that saves enough.

One modifier per Entity. A pitched or rolled box marks its shadow on the ground: the outline of its corners seen from above, between its lowest corner and its highest. A modifier on an entity attach() joined to a parent moves with the parent, and rebakes its tiles as it does. Where a world has more than one ground, a modifier marks the navmesh of the ground it stands on. Where two boxes overlap, the dearer cost wins, in whatever order they spawned, and an impassable box beats every cost. A navmesh holds up to 62 distinct costs, and Infinity takes none of them.

To check the boxes from a screenshot, draw the navmesh: <Landscape navmesh> in the scene, or window.__GAME_NAVMESH__(true) on a development page. Each cost draws in a colour of its own, and an impassable box as a hole.

A modifier that joins, moves, resizes or changes its cost rebakes the tiles it meets, as a collider’s change does. Once they swap in, every walker the world moves searches its route again; a player’s character keeps the route the player’s page predicted. A walker whose destination an impassable box now covers walks to the box’s edge and stops there, as a partial route ends. A page in a room bakes the same marks the room does, since the room streams NavMeshModifierTrait. A search that runs out of nodes before it crosses a wide costed area searches again at the open ground’s cost, so a point it can reach is never answered partial.

Unity’s NavMeshModifierVolume sets an area on a box, and its Areas table holds each area’s cost. Unreal’s NavModifierVolume sets a navigation area class whose DefaultCost scales the distance, and grows the marked footprint by the agent’s radius. Roblox’s PathfindingModifier labels a part, and CreatePath’s Costs prices each label. Godot puts travel_cost and enter_cost on a navigation region. Unity’s Not Walkable area, Unreal’s NavArea_Null and Roblox’s math.huge cost each mark ground no route crosses, as Infinity does here. Here the cost sits on the box itself, where an agent writes the box, and every walker shares it: none of the engine’s walkers has costs of its own yet.

A player controls the entities their input drives: the player’s character in most games, a drone or a kart beside it or in its place, or nothing at all in a card game. ControlledTrait holds the link: the controller, a player entity or none, the way it is simulated, Simulation.Predicted or Simulation.Server, and its control serial, a number each change of the link takes. Control changes on the room alone:

  • control(step, player, entity, { simulation }) makes the player control the entity from the next tick. The mode is required. A control of an entity another player holds hands it over in one change. Three options beside it: visibility: ControlVisibility.Controller hides who controls it from every page but the controller’s. context names the input context live on the player’s page while the player controls it. viewTarget: true makes it the player’s view target, the one the player’s camera follows.
  • tryControl(step, player, entity, { simulation, from: null }) returns { ok: true }, or { ok: false, refusal } with a ControlRefusal. The refusals are EntityGone, ControllerLeaving, NotControllable for a player or a room controller, NotAController for an entity that is neither, and ControlledByOther where from names another controller than the one that holds it. Two riders who reach for one seat in one tick get one { ok: true }. control throws the same refusals in development and logs them in a deployed room.
  • releaseControl(step, entity) clears the controller: the entity reads each input at rest, and its systems step it on.

Each call checks and reserves at once, and the change commits as the tick ends, so every system of a tick reads one controller per entity. findController(world, entity) reads the committed one, and findPendingController(step, entity) the one after this tick’s changes. readControlled(world, player) lists what the player controls, and readPendingControlled(step, player) what the player will control once the tick commits. A join hook may control the joining player’s own entities with its step, as the characters plugin controls the joining player’s character; a hook that reaches for another entity throws, which refuses the join. Destroying a controlled entity drops it from the player’s control at once, and a player who leaves releases everything they controlled.

The player’s input for each tick rides to the room once, whatever the player controls: the room writes it onto the player entity, where readInput(player, handle) reads it, and into each entity the player controls. The player’s page predicts each entity the player controls in Simulation.Predicted, as it predicts the player’s character: it steps the entity on the player’s input the moment the player presses. A correction restores and re-runs every one of them. useCharacter() and readLocalCharacter(world) read the character the local player controls, a character with its pose before a kart or a drone the player controls beside it. The room’s tests run two creators’ plugins against a real room, drone.ts and crank.ts: a drone the player flies in place of their character, and a game whose player has no character and plays through an axis of its own.

A plugin’s onControlRelease({ step, entity, controller, reason }) runs once for each control that ended, at the commit, in plugin order, so a plugin tidies up without a system that polls. The ReleaseReason is Released, HandedOver, EntityDestroyed, ControllerGone for a player who left or a room controller destroyed, or LevelChanged for an entity the room’s scene destroyed as it started again. The entity may be gone already, as the reason says. A control a hook stages commits at the next commit.

A hidden control streams its controller as none to every page but the controller’s: a prop hunt’s disguised player reads, on every other page, as the empty prop beside the disguised player. The controller’s own page learns of it in the controller’s acknowledgement, so findController there names the controller. No page but the controller’s receives a control’s serial, mode or context.

Room AI drives an entity through the input path a player’s page drives one through, so the entity’s own systems, its prediction and its tuning stay one code:

  • addController(step, { name }) makes a room controller: an entity control accepts, which is no player, never streams, and readPlayers leaves out. An NPC racer, an autopilot that lands a dropped pilot’s dragon, or a takeover of a dropped player’s hero each control through one. Destroying it releases what it controls. An entity it controls is simulated on the room alone.
  • addBotPlayer(step, { name }) fills a seat with a player of the role Role.Bot, with every plugin’s join hooks, so the characters plugin gives it a character and a scoreboard counts it. It holds no save, kick removes it, and the room’s close runs its leave with every player’s.
  • writeInput(step, controller, { handle, value }) writes one field of a room controller’s or a bot player’s input for the next tick, as a page sends a player’s before the tick it names. A field no system wrote for a tick reads at rest, an angle where it last stood. A player’s own input comes from the player’s page alone.

The autopilot, autopilot.ts in the room’s outside tests, is a creator’s plugin a test runs against a real room: a room controller drives an NPC kart until a player takes the wheel, and a player hides in a prop no other page sees the player control.

An input context is a named list of a plugin’s inputs with a priority, which a control names. A plugin declares one as contexts: { driving: inputContext({ priority: 10, inputs: ["throttle", "handbrake"] }) }. While the player controls an entity under it, the context is live on the player’s page.

Every input fills from its own keys, and a key two live contexts’ inputs share fills the higher one’s alone. W fills a kart’s throttle and not the player’s seated character’s walk, since the characters plugin controls the player’s character under characters.walking, whose priority is zero. A key a higher context took stays off the lower input until the player lets it go, so leaving the kart with W held walks nowhere until the player presses it again. An exclusive: true context, a menu’s, rests every input below it. Two live contexts of one priority that share a key throw in development. Two inputs may share a key only where each is listed in a context. As Unreal’s input mapping contexts and their priorities.

A touch control gives way to a higher live context whose inputs take every key its input has. A stick with no keys, such as the aim stick, gives way to a higher live context that lists a stick of its own, a vector input with keys or a touch stick. So a kart steered by its own stick, or by a vector on W, A, S and D, takes the aim stick, and one steered by axis and button inputs leaves it. In Unreal a touch stick is a gamepad stick, which a higher mapping context that maps that stick takes the same way.

Two references on the player entity say what draws and listens for the player, apart from what the player controls:

  • The view target is what the player’s camera follows: the player’s character, kart, a player being watched, a cutscene’s rig. ViewTargetTrait on the player entity names it, and the player’s own page alone receives it. setViewTarget(step, player, entity) moves it, and null hands the player’s camera to the scene’s camera; control(…, { viewTarget: true }) moves it as a control does. The player’s page reads it with useViewTarget(). While the player watches another, setIgnoreInput(step, player, true) holds every entity the player controls still: readInput reads each input at rest on the room and on the player’s own page, and the player’s page still sends commands. A match’s spectating sets it.
  • The presence is what stands for the player in the world, which the player’s nameplate hangs over: the player’s character in most games, the player’s dragon in a dragon game, none in a card game. PresenceTrait on the player entity names it, and every page receives it. setPresence(step, player, entity, { visibility }) moves it. visibility: ControlVisibility.Controller writes it as none on every page, the player’s among them since every page shares the stream, while the room keeps the entity, so no nameplate gives a disguised player away. findPlayerByPresence(world, entity) and usePlayerByPresence(entity) go from what stands for the player back to the player entity, which is how useDisplayName names a character.

The characters plugin makes the player’s character both as it spawns it. Watching another moves the player’s view target and never the player’s presence, so the watching player’s nameplate never moves over the watched player. Each change is checked at once and lands as the tick ends, with the controls: the last of a setViewTarget and a control with viewTarget: true in one tick wins. Destroying the entity either names clears it at once, and the player’s camera falls back to the scene’s camera. A player who drops keeps both through the hold; a player who leaves takes both with them, and one who joins again starts with none until a game sets them. Both take what control takes and refuse as it does: in development a call on an entity that is no player, or on a destroyed entity, throws.

The player’s page reads its player’s state with usePlayer(), the player entity, useCharacter(), the character, useViewTarget(), what the camera follows, and useControlled(trait?), what the player controls. readLocalPlayer(world) reads the player entity outside a component. isControllerHeld(world, entity) says whether the player who drives an entity dropped, which ConnectionTrait on the player entity holds, so a game leaves a held player’s character out of a vote or a chase.

A plugin that points the player’s camera at the next player’s character on N, and back at the player’s own after the last, from packages/room/test/outside/spectate.ts, which a test runs against a real room:

import type { Entity, World } from "@spawnite/engine/core";
import {
buttonInput,
definePlugin,
PresenceTrait,
readInput,
readPlayers,
readTrait,
setViewTarget,
ViewTargetTrait,
type AuthoritativeStep,
defineSystem,
Phase,
} from "@spawnite/engine/core";
// Watching another player, built as a creator's plugin is, from the
// engine's public entry alone: N points the local player's camera at
// the next player's character, then back to the local player's after
// the last. The local player's presence stays put, so that player's
// nameplate never moves over the player being watched.
export const spectators = definePlugin(() => ({
name: "spectators",
inputs: { watch: buttonInput({ keys: ["KeyN"], edge: true }) },
systems: [
defineSystem({
name: "watchNext",
phase: Phase.Rules,
run: watchNext,
}),
],
}));
/** What stands for `player` in the world, or null for nothing. */
function readPresence(player: Entity) {
return readTrait(player, PresenceTrait)?.entity ?? null;
}
/** Moves the view target of each player who pressed N to the next
* player's presence, and back to the original presence after the
* last. */
function watchNext(step: AuthoritativeStep) {
const world = step.world;
const players = readPlayers(world);
for (const player of players) {
if (!readInput(player, spectators.inputs.watch)) continue;
const own = readPresence(player);
const watched = readTrait(player, ViewTargetTrait)?.entity ?? own;
const others = players
.map(readPresence)
.filter((presence) => presence !== null && presence !== own);
const next = others[others.indexOf(watched as Entity) + 1] ?? own;
setViewTarget(step, player, next);
}
}

Unreal splits the same two: a player controller’s view target, which SetViewTarget moves, and the pawn it possesses. Roblox’s camera follows CameraSubject apart from Player.Character, and its nameplate hangs on the character. Unity, Godot and PlayCanvas leave both to the game. Here both are the core’s, so the camera, the nameplates and the voice list read one place.

Unreal possesses one pawn per controller, on the server, and Photon Fusion gives one player input authority over any number of objects, each reading that player’s tick’s input. Control here takes Fusion’s shape with Unreal’s rule that the room alone possesses. Unlike Possess, a control is visible at once only through findPendingController, and every system reads the committed link.

characters() gives each player a character once the player’s save has restored onto the player entity, in its onPlayerReady: a bot player gets one too. It spawns the character at the player’s team’s spawn point or seat’s, from the scene’s <SpawnPoints>, or on the ring round the scene’s <CharacterSpawn>, with the <CharacterSpawn>’s props, and runs each plugin’s onCharacterSpawn. In a game with teams, a player with no team gets no character until the player has one, as Teams says. It registers the character as the player’s saved entity under main, so the player’s save restores over those defaults, and makes it the player’s view target and presence; in a room the player controls it, predicted.

In a game played alone the player’s join runs before the scene mounts, so the scene’s <CharacterSpawn> has the plugin spawn the character as it mounts, and destroys it as the scene goes. The character is captured into the player’s save, so the next scene’s character carries its bag. findCharacter(world, player) reads it on the world that decides outcomes, and on the local player’s page for that player, as Roblox’s player.Character; useCharacter() reads the character on the player’s page. findCharacterPlayer(world, character) reads the other way, as Roblox’s Players:GetPlayerFromCharacter, and answers null for an NPC’s. The player’s character goes with the player as the player leaves.

  • onCharacterSpawn({ writer, character, player, props }) runs once per spawned entity, in plugin order, before the player’s save restores: what a plugin adds to every character, a trait, a bag, an ability. player is the character’s PlayerEntity, or null for a character no player plays, as a story or a test spawns one bare.
  • onCharacterRespawn({ writer, character, player }) runs as a downed character stands again: the same entity, so a game refills its ammo or clears its buffs there, where a Roblox game puts it in CharacterAdded. respawnCharacter(step, character, { position, rotation }) stands one again from a game’s own system, such as at a checkpoint it chose, facing rotation where given, and runs the hook. At a point it places it as Health says, and a brand-new body is spawnCharacter’s, below. A character that strafes turns back toward the camera’s heading on its next steps, because the room’s step cannot turn the player’s camera: a view that hears the respawn turns it with frameCamera.
  • spawnCharacter(step, player, { position, facing, props, savedAs, restore }), from @spawnite/engine/core, spawns the player’s character itself and answers it. A character the player has goes first, captured into the player’s save as it goes, so a game that destroys and spawns again, as Roblox’s LoadCharacter does, keeps the character’s bag. props are laid over the scene’s, for a knight, a mage or a rogue from one scene, and its appearance comes from them on every page where they name one. An explicit position and facing win over the character’s saved place, and so does a point placed for the player’s team, unless restorePlace is set. savedAs names another saved entity, which is a character switch, and restore: false starts the character fresh, as a roguelike’s new run does. In a room the player’s page recognizes the new character as the player’s own once the room’s word on it lands, so the player’s next click walks it.
  • characters({ view }) draws every character with the game’s own view, as Your own character view says.
  • characters({ autoSpawn: false }) spawns no character on its own, for a game that spawns them itself: from a choice the player’s save keeps, at a lobby’s round start, or never, as a dragon game whose plugin spawns a dragon does.
  • characters({ movement, controller, capsule }) sets what every player’s character spawns with, under the scene’s <CharacterSpawn> props, as the chain says. movement is a MovementPreset or single settings, controller a partial CharacterControllerTrait, and capsule a partial capsule, radius, height and collisionMask, the same for every player whatever avatar the character wears. collidesWithCharacters: false lets players walk through each other, as Collision layers says.
  • characters({ teamChange, spawnWithoutTeam, restorePlace }) sets what a team does to the player’s character, as Teams says. teamChange is what the player’s own switch or a balance does to the player’s living character: TeamChangeEffect.Die by default, Respawn or Stay. spawnWithoutTeam: true spawns a player with no team on the points placed for no team. restorePlace: true restores the player’s saved place over the player’s team’s points.
  • characters({ outOfWorld }) sets what a fall below the scene’s killBelowHeight does to a living player’s character: OutOfWorldEffect.Die by default, Respawn or None, as Health says.
  • characters({ poseTolerance, smoothing }) sets how the player’s page compares and draws a correction of the player’s character in a room, the options control takes. The control the plugin makes carries them for every character it spawns, by itself or through spawnCharacter. Each part left out takes the default. That is 5 cm, a jump past 2 m or past 0.4 s of the character’s speed where that is farther, and an ease of at most 0.4 s, as Predicting a mechanic says. A game whose characters run at 12 m/s may set characters({ poseTolerance: { position: 0.1 } }). A game that calls control on the player’s character itself names that call’s own options, and each part it leaves out takes the default, not what characters() names.

A saved entity is an entity the player’s save keeps by the name it is saved as: the player’s character saved as main, each character of a party by its own name, a pet saved as pet. Registering one restores that name’s record over what its spawn set up; losing it, by releaseSavedEntity, a destroy or the player’s leave, captures it first, and a name with no live entity keeps what it last captured or loaded. The engine’s entity, stats, resources and inventory saves and every save kept in the entity scope are kept this way, as Saving progress says, and what outlives a character, the player’s coins and choices, lives on the player entity.

A saved entity need not be a character. A chest or a stash with a bag is one too: each save keeps its state on the saved entities that hold the traits its with lists, so the core’s position and health skip a chest with no transform or health, and the bag keeps its slots. Declare what the save keeps lists the field.

  • setSavedEntity(step, player, entity, { savedAs, restore }) registers entity saved as savedAs, main when left out. Registering another saved as the same name replaces the one there, captured first.
  • releaseSavedEntity(step, player, { savedAs }) captures the entity saved as savedAs and stops keeping it; it stays in the world.
  • findSavedEntity(world, player, { savedAs }) reads the entity saved as savedAs, or null.

The following plugin is a party of three a player switches between. The choice of who is out belongs to the player, kept on the player entity and restored before the player’s ready hook spawns that one. Each character keeps its own health by the name it is saved as. A switch, a command the player’s page sends as sendCommand(world, party.commands.switchTo, { to: "mage" }), captures the one that goes:

packages/engine/test/outside/party.ts
import { z } from "@spawnite/schema";
import {
defineCommand,
definePlugin,
defineSave,
defineTrait,
findCharacter,
oneOf,
readCommands,
spawnCharacter,
TransformTrait,
type AuthoritativeStep,
type CharacterSpawnProps,
addTrait,
setTrait,
defineSystem,
Phase,
} from "@spawnite/engine/core";
import { characters } from "@spawnite/engine/characters";
// A party of three characters a player switches between. Each keeps its
// own bag, stats and health by the name it is saved as; the choice of
// who is out is the player's, kept on the player entity.
/** Each character's props, laid over the scene's `<CharacterSpawn>`. */
export const classes = {
knight: { health: { current: 80, maximum: 80 }, color: "silver" },
mage: { health: { current: 45, maximum: 45 }, color: "purple" },
rogue: { health: { current: 60, maximum: 60 }, color: "green" },
} satisfies Record<string, CharacterSpawnProps>;
type ClassName = keyof typeof classes;
function isClass(name: string): name is ClassName {
return Object.hasOwn(classes, name);
}
/** Who is out, on the player: the player's save keeps it. */
export const PartyTrait = defineTrait("party", { selected: "knight" });
/** Switches each sender's character to the one the sender asked for: the
* old one is captured into its key as it goes, and the new one restores
* its key's record, standing where the old one stood. */
function switchCharacters(step: AuthoritativeStep) {
const world = step.world;
for (const command of readCommands(step, party.commands.switchTo)) {
const { player } = command;
const { to } = command.payload;
const old = findCharacter(world, player);
spawnCharacter(step, player, {
savedAs: to,
props: classes[to],
position: old?.get(TransformTrait)?.position.clone(),
});
setTrait(step, player, PartyTrait, { selected: to });
command.accept();
}
}
export const party = definePlugin(() => ({
name: "party",
// The room refuses a class outside the list before the reader runs.
commands: {
switchTo: defineCommand({ to: oneOf(["knight", "mage", "rogue"]) }),
},
saves: {
party: defineSave({
scopes: ["player"],
version: 1,
schema: z.object({ selected: z.string() }),
read: ({ player }) => ({
selected: player.get(PartyTrait)?.selected ?? "knight",
}),
restore: ({ writer, player }, { selected }) => {
setTrait(writer, player, PartyTrait, { selected });
},
}),
},
// Before the player's save restores, which overwrites the default.
onPlayerJoin: ({ step, player }) => {
addTrait(step, player, PartyTrait);
},
// Once it has, so the player's saved choice picks who spawns.
onPlayerReady: ({ step, player }) => {
const selected = player.get(PartyTrait)?.selected ?? "knight";
const savedAs = isClass(selected) ? selected : "knight";
spawnCharacter(step, player, { savedAs, props: classes[savedAs] });
},
// A command's reader runs on the room alone, or the one world of a
// game played alone.
systems: [
defineSystem({
name: "switchCharacters",
phase: Phase.Rules,
answers: ["switchTo"],
run: switchCharacters,
}),
],
}));
// The party spawns each character itself.
export const plugins = [characters({ autoSpawn: false }), party()];

Roblox’s LoadCharacter makes a new character and leaves what it keeps to the game’s own DataStore code; Unreal’s RestartPlayer spawns a new pawn and keeps a player’s state on the PlayerState. Here the save follows each saved entity by the name it is saved as, so a new character saved as the same name carries what the old one had, and one saved as another name is another character.

readIdleSeconds(world, player) reads the seconds since the player last did something: held an input off its rest, turned the player’s look, or sent a command, to the second. A bot is never idle. Every page reads it from the room’s stream, so a lobby greys out an idle player and their own page warns the player. A match’s idleSeconds reads it to send an idle member out.

The player’s page, and in a room the room too. The player entity and every entity the player controls in Simulation.Predicted say RunContext.Client on the player’s page, so the player’s page runs them ahead of the room; everything else spawns under the server’s authority. In a room, the room also runs each of the player’s moves from the player’s input and has the final say, and the player’s page takes its correction. Multiplayer says how.

import {
CharacterSpawn,
Landscape,
registerModel,
scatterModels,
} from "@spawnite/engine";
registerModel("tree-round", scatterModels.treeRound);
export function Run() {
return (
<Landscape map="meadow">
<CharacterSpawn model="tree-round" position={[0, 0, 4]} />
</Landscape>
);
}

A rigged model the character wears, in a glowing material over its own texture, playing a file’s Sprint as its run:

packages/engine/test/outside/SpiritModel.tsx
import { MeshStandardMaterial, type Material } from "three";
import { CharacterSpawn, registerModel, Landscape } from "@spawnite/engine";
/** The file's texture, lit from within. */
function glow(original: Material) {
const map = original instanceof MeshStandardMaterial ? original.map : null;
return new MeshStandardMaterial({
map,
emissiveMap: map,
emissive: "#8fbcff",
});
}
/** Registers the spirit from `path`: its glow, and the file's `Sprint` as
* the character's run, on every page that draws the character. */
export function registerSpirit(path: string) {
return registerModel("spirit", {
path,
material: glow,
clips: { run: "Sprint" },
});
}
export function Run() {
return (
<Landscape map="meadow">
<CharacterSpawn model="spirit" />
</Landscape>
);
}

A VRM body the character wears with its clips:

packages/engine/test/outside/HeroineAvatar.tsx
import {
CharacterSpawn,
registerAvatar,
Landscape,
type VrmBody,
} from "@spawnite/engine";
/** Her body: the VRM file, its scale and how far its arms stand off it. */
function readHeroine(model: string): VrmBody {
return {
model,
scale: 1,
armSpread: {
left: { out: 0, forward: 0 },
right: { out: 0, forward: 0 },
},
};
}
/** Registers her body from `model` under the name every page draws. */
export function registerHeroine(model: string) {
return registerAvatar("heroine", readHeroine(model));
}
export function Run() {
return (
<Landscape map="meadow">
<CharacterSpawn avatar="heroine" position={[0, 0, 4]} />
</Landscape>
);
}