Godot Game Loop Time Trial logo

Godot Game Loop Time Trial

Community
thedivergentai
godot-game-loop-time-trial

Expert patterns for racing mechanics, checkpoint tracking, and ghost recording/playback in Godot 4. Use when building racing games, speed-run platformers, or arcade trials.

Overview

Publisherthedivergentai
RepositoryGD-Agentic-Skills
Skill namegodot-game-loop-time-trial
Stars
727
Forks
43
Bundled files
8
LicenseLGPL-3.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 8 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by thedivergentai on GitHub. Read the source before you install it.

Installation

Install the Godot Game Loop Time Trial AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/thedivergentai/GD-Agentic-Skills.git /tmp/GD-Agentic-Skills
mkdir -p .claude/skills
cp -r /tmp/GD-Agentic-Skills/skills/godot-game-loop-time-trial .claude/skills/godot-game-loop-time-trial
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Godot Game Loop Time Trial in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Godot Game Loop Time Trial on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Godot Game Loop Time Trial is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Architectural Thinking: The "Validation-Chain" Pattern

A Master implementation treats Time Trials as a State-Validated Sequence. Recording a time is easy; ensuring the player didn't cheat via shortcuts requires a strictly ordered CheckpointManager.

Core Responsibilities

  • TimeTrialManager: The central clock. Validates checkpoint order and handles "Best Lap" logic.
  • GhostRecorder: Captures high-frequency transform data. Uses delta-time timestamps for frame-independent playback.
  • Checkpoint: Spatial triggers that notify the Manager.

Expert Code Patterns

1. Robust Checkpoint Validation

Prevent "Shortcut Cheating" by requiring checkpoints to be cleared in numerical order.

Wire Area body_entered (physics) → TimeTrialManager.pass_checkpoint(index). The manager owns usec timing — see script.

2. Space-Efficient Ghosting

Sample at a fixed rate (e.g. 10 Hz). Lerp position; slerp Quaternion rotation (ghost_recorder.gd / ghost_replayer.gd). Never Euler-lerp ghost heading.

Master Decision Matrix: Data Storage

FormatBest ForImplementation
Dictionary ArrayPrototypingSimple [{t: 0.1, p: pos}, ...]
Typed ArrayPerformancePackedVector3Array for positions.
JSON/BinarySavingFileAccess.get_var() to save ghost files.

NEVER Do

  • NEVER use OS.get_ticks_msec() for ultra-precise race timing — Millisecond resolution is too coarse for high-end racing games. Use Time.get_ticks_usec() for microsecond precision.
  • NEVER rely exclusively on _process() for finish line triggers — Visual frames can skip during lag. Always evaluate physical overlaps in _physics_process() to guarantee detection within the fixed physics step.
  • NEVER evaluate Area3D overlaps immediately after instantiation — The physics server requires at least one physics frame to synchronize. await get_tree().physics_frame before checking for players.
  • NEVER scale a CollisionShape3D on a checkpoint non-uniformly — This breaks the underlying SAT collision math. Always scale the internal shape resource (e.g., BoxShape3D.size) instead.
  • NEVER use TCP (reliable) for syncing positions in multiplayer racing — Congestion algorithms cause huge spikes. Use ENetMultiplayerPeer with TRANSFER_MODE_UNRELIABLE for high-frequency position updates.
  • NEVER trust client-side finish line/lap crossing — Always validate triggers on the authoritative server using multiplayer.is_server() to prevent cheating.
  • NEVER use standard float equality (==) for record lap times — Use is_equal_approx() to account for precision loss in accumulated time variables.
  • NEVER hardcode input checks without flushing the buffer — For frame-perfect boost/stop responses, call Input.flush_buffered_events() to ensure the engine has processed the latest raw input.
  • NEVER allocate new Vector3 arrays inside fast path-following loops — This triggers the garbage collector. Use PackedVector3Array to maintain a contiguous memory block.
  • NEVER use dynamic string paths ($"../Checkpoint") in tight loops — Lookups are slow. Use @onready to cache node references during initialization.
  • NEVER record the whole player object for ghosts — Only record core transforms (position/rotation). Recording the whole object is memory-intensive and unnecessary for visual ghosts.
  • NEVER give the ghost collision — It should be a purely visual indicator (e.g., semi-transparent) to avoid disrupting the player's line.
  • NEVER neglect checkpoint sequencing — Don't just check if the player hit the finish line. Verify they passed every intermediate checkpoint in the correct order.
  • NEVER use Area3D without monitoring optimization — Checkpoints should only look for the Player physics layer to minimize the number of physics overlap calculations.
  • NEVER use standard lerp for ghost rotation — Use slerp() or Quaternion.slerp() to avoid gimbal lock and ensure smooth rotation interpolation.

Available Scripts

MANDATORY: Follow the golden path order. Read each listed script before coding that stage.

Golden path (MANDATORY)

  1. time_trial_manager.gd — microsecond (Time.get_ticks_usec) or physics-frame clock; pass_checkpoint only from physics overlaps / Area signals
  2. Checkpoint Areas — ordered indices into the manager (physics frame, not _process)
  3. ghost_recorder.gd — samples {t, p, q} with Quaternion rotation
  4. ghost_replayer.gd — position lerp + Quaternion slerp (never Euler lerp)
  5. time_trial_leaderboard_bridge.gd — integer usec/msec → UI strings

Script index

time_trial_patterns.gd

10 Expert patterns: Microsecond timing, server-authoritative validation, rubber-banding AI, and frame-perfect input flushing.

time_trial_manager.gd

Central clock. Accumulates Time.get_ticks_usec() (or physics-frame counts). Finish checks must come from physics overlaps.

ghost_recorder.gd

Captures transform samples with Quaternion "q" fields for slerp-safe playback.

ghost_replayer.gd

MANDATORY with recorder. Replays samples via position lerp + Quaternion.slerp.

time_trial_playback_buffer.gd

Jitter-buffer for smooth ghost playback during network streaming.

time_trial_leaderboard_bridge.gd

Formatting utility for converting raw time data to human-readable strings.


Expert Time Trial Patterns

1. Delta-Compression for Ghosts

Store a keyframe only when position/rotation changes beyond a threshold. Persist with FileAccess.open_compressed() + ZSTD; prefer binary floats over JSON.

2. The Leaderboard Bridge

Store records as int usec/msec. Format with %02d:%02d.%03d for stable UI (e.g. 01:24.450).

Expert knowledge (on demand)

LLM-ignorance rule: If a general agent would not know it before reading, load the reference — never delete expert deltas.

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.

Official Documentation

  • Timeget_ticks_usec() for microsecond lap clocks when OS.get_ticks_msec() is too coarse for race records.
  • Idle and Physics Processing — why finish-line and checkpoint overlap must run in _physics_process, not visual _process frames that can skip under load.
  • Area3D — monitoring, collision masks, and body_entered for ordered checkpoint gates without scanning every physics body.
  • Collision shapes (3D) — scale shape resources (BoxShape3D.size) instead of non-uniform CollisionShape3D scale so SAT stays valid on gates.
  • Using transforms — global position/basis capture for ghost samples and why Euler-only storage needs careful replay conversion.
  • Quaternionslerp() between keyframes so ghost heading avoids gimbal lock from naive Euler lerp.
  • Transform3Dinterpolate_with() for jitter-buffered network ghost playback between ordered frames.
  • Saving gamesFileAccess / store_var patterns for persisting ghost runs and best-time dictionaries without float display round-trips.
  • High-level multiplayer — server-authoritative RPC validation so clients cannot fake lap/finish crossings.
  • MultiplayerPeerTRANSFER_MODE_UNRELIABLE for high-frequency racer transforms where TCP-style reliability spikes latency.
  • Inputflush_buffered_events() when frame-perfect boost/stop must see the latest raw input before the physics step.
  • Enginephysics_ticks_per_second / get_physics_frames() for integer frame-count timing bridges into MM:SS.mmm UI.

Related Skills

Prerequisites
  • godot-project-foundations — scene tree, autoloads, and resource layout before wiring a TimeTrialManager and checkpoint Areas into a track scene.
  • godot-physics-3d — Area3D/CollisionShape3D layers, RigidBody/CharacterBody vehicles, and physics-frame overlap rules that make checkpoint sequencing trustworthy.
  • godot-signal-architecture — typed lap/split/finish signals between gates, manager, HUD, and ghost systems without brittle node-path coupling.
  • godot-gdscript-mastery — typed arrays, Packed* buffers, await physics_frame, and RPC annotations used in timing and authority patterns.
Complements
  • godot-input-handling — action maps and buffered boost/steer input that time-trial NEVER rules require to flush before physics.
  • godot-save-load-systems — compressed binary ghost files and best-time persistence beyond in-memory sample arrays.
  • godot-multiplayer-networking — ENet peers, authority, and unreliable transform sync for live races and streamed ghost frames.
  • godot-adapt-single-to-multiplayer — lag compensation, snapshots, and interest patterns when elevating a solo time trial into online racing.
  • godot-navigation-pathfinding — NavigationServer3D agent max-speed for rubber-band AI that paces against the player without cheating collision.
  • godot-monte-carlo-balancer — simulate rubber-band factors, checkpoint difficulty, and target clear times before shipping trial parameters.
  • godot-camera-systems — chase/replay cameras that must track live cars and non-colliding ghost visuals during playback.
Downstream / consumers
  • godot-genre-racing — full racing genre stack that consumes checkpoint clocks, ghosts, and leaderboard formatting as core loop primitives.
  • godot-game-loop-collection — meta inventory/collection loops that can gate unlocks on validated best times from this skill.
Master
  • godot-master — library router and mirrored module entry for cross-skill discovery.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Godot Game Loop Time Trial AI skill do?

Expert patterns for racing mechanics, checkpoint tracking, and ghost recording/playback in Godot 4. Use when building racing games, speed-run platformers, or arcade trials.

Why use Godot Game Loop Time Trial on TypingMind?

Because you install it once and use it with any model. Godot Game Loop Time Trial is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Godot Game Loop Time Trial in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/thedivergentai/GD-Agentic-Skills/tree/main/skills/godot-game-loop-time-trial. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Godot Game Loop Time Trial?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Godot Game Loop Time Trial?

As many as you like. As long as a model supports skills, you can use Godot Game Loop Time Trial with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Godot Game Loop Time Trial AI skill free?

Yes. It is published on GitHub by thedivergentai under the LGPL-3.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇