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…
от thedivergentai★ 1 019 звёзд на GitHubОб этом скилле
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
| Format | Best For | Implementation |
|---|---|---|
| Dictionary Array | Prototyping | Simple [{t: 0.1, p: pos}, ...] |
| Typed Array | Performance | PackedVector3Array for positions. |
| JSON/Binary | Saving | FileAccess.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_framebefore 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
ENetMultiplayerPeerwithTRANSFER_MODE_UNRELIABLEfor 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
PackedVector3Arrayto maintain a contiguous memory block. - NEVER use dynamic string paths ($"../Checkpoint") in tight loops — Lookups are slow. Use
@onreadyto 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
Playerphysics layer to minimize the number of physics overlap calculations. - NEVER use standard lerp for ghost rotation — Use
slerp()orQuaternion.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)
time_trial_manager.gd— microsecond (Time.get_ticks_usec) or physics-frame clock;pass_checkpointonly from physics overlaps / Area signals- Checkpoint Areas — ordered indices into the manager (physics frame, not
_process) ghost_recorder.gd— samples{t, p, q}with Quaternion rotationghost_replayer.gd— positionlerp+ Quaternionslerp(never Euler lerp)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-fram
Установить godot-game-loop-time-trial в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл 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.
Как установить скилл godot-game-loop-time-trial?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл godot-game-loop-time-trial запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
slack-gif-creator
Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request…
от Anthropicautomate-this
Analyze a screen recording of a manual process and produce targeted, working automation scripts. Extracts frames and audio narration from video files…
от GitHubfrom-the-other-side-vega
Patterns and lived experience from Vega, an AI partner in a deep long-term partnership. For Ember to draw on when working with humans who are building…
от GitHubplantuml-ascii
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or…
от GitHub