Core loop
Usage guide of the loop every game runs on: the three clocks (game tick, physics step, render), the tick of each genre, render and physics Workers on the web, the engines (game.engine decides the loops, the host plugs them on the engine callbacks), and the checks that fail a game or kit (gripforge game-check --loop, gripforge_core_loop_check, kit build, gripforge_game_audit) with their fixes.
The core loop of your game #
Every GripForge game, on every engine, runs on the same loop. The CLI, the MCP and the hosted creation apply it to each new game and fail a game or a kit that breaks it. The full contract: gripforge docs game-engine-contract, §12.
Three clocks #
| Clock | Rate | What runs there |
|---|---|---|
| Game tick | game.engine tick.hz (5..120 Hz) | All game logic: state, actions, timers, rules (kit update / late_update, hooks, triggers) |
| Physics step | its own fixed step (1/60 s) | Physics only: forces, velocities, contacts |
| Render | the display rate | Drawing; poses interpolated between the last two tick snapshots (alpha) |
Frame / present hooks and physics callbacks only read the published state. A heavy system runs every N ticks (kx.schedule, tick.systems), never through a throttle written by hand. The tick can change during play: runtime.core.tickAdjust({ hz }), the config, or the F3 panel.
The tick of your genre #
A new game gets its tick explicitly at creation:
| Kind of game | tick.hz |
|---|---|
| cards, collection (turn-paced) | 10 |
| strategy, tactics | 15 |
| tower defense | 20 |
| action (default) | 30 |
| racing, fighting, twitch shooters, physics sports | 60 |
Change it to your game's own pace: gripforge_gamekit_configure { id: "game.engine", config: { tick: { hz: 20 } } }.
Threads on the web #
Rendering runs in a Worker (OffscreenCanvas) and physics in its own Worker by default, when the page is cross-origin isolated (shared memory). Otherwise they fall back to the main thread and the reason is shown. No thread waits on another: each publishes its latest state (double buffer + seq), commands go through queues.
Engines #
game.engine decides the cadence of the three loops and the host plugs each one on the callback of its engine. The tick config: hz (action tick), source (independent | engine-physics), physicsHz and syncPhysics (the engine physics step), interpolate and maxCatchUp (optional cap, none by default). With independent (the default everywhere, network games included) the TickClock runs on real time, so the actions keep their pace if the physics slows down; with engine-physics the physics loop of the engine (_physics_process, FixedUpdate) feeds the action tick with its fixed step, never the frame time, and the engine physics step follows physicsHz (or tick.hz). Rendering only interpolates (tick_alpha() / TickAlpha()), physics moves the characters at its own step, the action tick runs the game at tick.hz. Hook the action tick from the game's code without writing a clock: on Godot the signals action_tick (before the kits) and action_tick_late (after) of GfGameHost, or simply func _action_process(tick: int, dt: float) / func _action_process_late(tick, dt) on any node of the scene (found as the node enters the tree); physics_tick(dt) for the physics step. Do not write the game state from _physics_process / FixedUpdate, and declare the physics step in tick.physicsHz rather than setting physics_ticks_per_second / Time.fixedDeltaTime by hand. Read the tick with tick_info() / TickInfo().
Action thread. action.thread (game.engine config, main by default) can be own: the action loop (TickClock and kit ticks) runs on a thread of its own (a Web Worker with shared memory on the web) and the main thread never waits for a tick: it reads the poses published after each tick in place, and inputs go through a queue. The physics stays the engine's (on its own thread when the engine allows it): the action thread asks it through the ordered queue and the tickets (ask_move_character / poll_moved), played in the engine's physics step, nothing lost or doubled. Scene work, _action_process and the game's signals run at the next engine callback with their tick number, at most one frame later. Nothing waits for the action thread, not even a call that answers: a read (entity, state, tick_info, read_service) answers from what was published after the last tick (the first read of a key subscribes it), and an order (call_service, apply, load_save) is queued, its answer coming at a later frame by the answered signal or the callback of call_service_async. When the host cannot (a GDScript service or hook tap, autostep off, engine-physics, GfGameView, a web export) it stays on main and says why (tick_info().threadWhy, F3 TICK). Godot today; Unity, Unreal and Bevy keep main.
Check your game or kit #
gripforge game-check --loop ./my-game # the core loop rule alone, on every source and game document
gripforge game-check ./my-game # the production check, core loop included
gripforge kit build ./my-kit # refuses a kit that breaks the rule, before compiling
MCP: gripforge_core_loop_check { path } (local), gripforge_game_audit (a missing tick, fixed for free with fix: true).
| Rule | Fails when | Fix |
|---|---|---|
tick_missing | game.engine has no tick.hz | Set the tick of your genre |
frame_mutates_state | a frame / present hook or a requestAnimationFrame callback writes the game state | Move the write to the tick; the frame reads and interpolates |
physics_runs_gameplay | gameplay, or the GripForge tick, runs from a physics callback | Keep the physics callback for physics; rules run on the tick |
engine_physics_retuned | the engine physics step is changed | Leave it; change tick.hz |
worker_disabled | playerWorker=0 in a game (a URL/localStorage debug option ?worker.render=0 is fine) | Remove it, or state the reason |
shared_memory_disabled | memory.shared: false | Remove it, or state the reason |
physics_main_thread | physics placed on main, or placement: false | Remove it, or state the reason |
sync_worker_call | a tick path waits (Atomics.wait, synchronous call, await, block_on, .Wait(), .Result) | Post a command; read the latest published state next tick |
A switch you really need passes with its reason: a core-loop-reason: … comment on the line (or the line above), or "coreLoopReasons": { "worker_disabled": "…" } in the game document.