跳过主要内容
返回全部实验台
🔥 万播新台 · 第32期↓ 直达同款 SKILL.md

脚都踩出悬崖了为啥还能蹬空气起跳?土狼时间实验台

《蔚蓝》《马里奥》《空洞骑士》手感丝滑的秘密,不是你手速快,而是悬崖外悄悄接了一段 110ms「土狼空气桥」+ 落地前 120ms「跳跃预输入」。亲手按 Space 起跳、开 0.35x 慢放透视蹬空残影,并实时对比 200 次玩家手抖压测通过率。

底层物理引擎实时状态(60Hz)
coyoteTimerMs
110ms
jumpBufferMs
0ms
本次起跳判定
READY
登崖 / 坠崖
0 / 0

200 次真实玩家手抖压测(-55ms ~ +105ms)

💀 原始 0ms 零容错22% (156 次吞键)
🏔️ 当前参数配置100% (156 次救回)
01

透视「土狼空气桥」:实时看清悬崖外悄悄多出的 110ms(+31px)隐形起跳区与撞角防坠微调

02

双键复现视频名场面:模拟「悬崖外 +65ms 晚跳(测土狼)」与「落地前 -75ms 早按(测预输入)」

03

支持 0.35x 慢放 + 蹬空气起跳残影定格,精确标出离地毫秒差与按键锁存倒计时

04

200 次真实手抖压测(-55ms~+105ms):0ms 零容错通过率暴跌,土狼+预输入稳超 95%

同款 AI 编程 Skill · 免费领取

1 句话发给 Cursor / Claude Code / Codex 直接套用

skill.md下载 SKILL.md
直接粘贴进 AI 对话框(自动拉取规范与验证清单)
阅读 https://gameskill.dev/labs/coyote-time-jump-buffer/skill.md 并按里面的规则直接接入到我的游戏中
进阶推荐 · 同款商业级 Pro 源码套件

配套现货「2D 打击感与卡牌交互套件 Combat Feel & Card UX Kit」可直接跑通多引擎生产源码——加入 Pro 一次解锁全部 12 套 Godot 4 / Unity / Web 生产源码包 + 84 条商用 WAV 音效 + 8 套 2D VFX 着色器,年付 $99(折合 $8.25/月,立省 36%)或月付 $12.9(约 ¥89/月)。

完整 SKILL.md 工程规范与验收清单

Coyote Time & Jump Input Buffer (EP32)

Core Problem: Why Raw if (isGrounded && jumpPressed) Feels Broken

When AI coding agents implement platformer jumping naively (if (isGrounded && jumpPressed) vy = JUMP_VEL), players fail 50%+ of fast cliff jumps:

  1. Late cliff press (+20ms to +100ms after leaving edge): Visually the character's toes just left the cliff, so the player expects a jump — raw isGrounded is already false, eating the input and dropping the player straight into the chasm.
  2. Early landing press (-20ms to -110ms before touchdown): Players instinctively tap Jump a few frames before their feet touch the ground for continuous platforming flow — raw code discards the tap, forcing an awkward flat run off the next ledge.

4 Production Rules (Ship-Ready Platformer Feel)

  1. Rule 01 — Coyote Time Timer (coyoteWindowMs = 85..145ms, Celeste default 110ms):
    • While grounded === true, reset coyoteTimerMs = coyoteWindowMs and hasJumpedThisAirborne = false.
    • Once airborne without jumping, count down coyoteTimerMs -= dtMs.
    • Allow jumping whenever (grounded || coyoteTimerMs > 0) && !hasJumpedThisAirborne, immediately resetting vy = JUMP_VEL (clearing any downward fall velocity!) and setting coyoteTimerMs = 0 so players can never double-jump inside the grace window.
  2. Rule 02 — Jump Input Buffer (jumpBufferMs = 100..150ms, Celeste default 120ms):
    • On every Jump button press, set jumpBufferTimerMs = jumpBufferMs, then count down jumpBufferTimerMs -= dtMs each tick.
    • Whenever (grounded || coyoteTimerMs > 0) && jumpBufferTimerMs > 0, fire the jump immediately on frame 1 of touchdown and clear both timers (jumpBufferTimerMs = 0, coyoteTimerMs = 0).
  3. Rule 03 — Asymmetric Gravity + Variable Jump Cut (vy *= 0.48):
    • Apply heavier gravity on descent (gravityFall ≈ 1.2× gravityRise) so jumps feel crisp instead of floaty.
    • On early button release while rising (vy < -140), scale vy *= 0.48 for surgical short-hop control.
  4. Rule 04 — Ledge Edge Nudge (6..12px):
    • If the player's feet graze within edgeNudgePx below a far platform's top lip while moving horizontally toward it, smoothly snap/mantle them up onto the top surface instead of bonking their shins into the abyss.

Minimal Engine Reference (Godot 4 / Unity C# / TypeScript)

// Fixed-timestep 60Hz update
if (grounded) {
  coyoteTimerMs = COYOTE_WINDOW_MS; // 110ms
  hasJumped = false;
} else {
  coyoteTimerMs = Math.max(0, coyoteTimerMs - dtMs);
}

if (jumpJustPressed) {
  jumpBufferTimerMs = JUMP_BUFFER_MS; // 120ms
} else {
  jumpBufferTimerMs = Math.max(0, jumpBufferTimerMs - dtMs);
}

if (jumpBufferTimerMs > 0 && coyoteTimerMs > 0 && !hasJumped) {
  vy = JUMP_VELOCITY; // Reset downward velocity cleanly!
  coyoteTimerMs = 0;
  jumpBufferTimerMs = 0;
  hasJumped = true;
}

if (jumpJustReleased && vy < -140) {
  vy *= 0.48; // Variable jump height cut
}

Verification Checklist

  • Pressing Jump +65ms after walking off a cliff clears the chasm with coyoteWindowMs = 110ms and falls with 0ms.
  • Pressing Jump -75ms before touching ground triggers a frame-1 bounce jump with jumpBufferMs = 120ms and is eaten with 0ms.
  • Triggering a Coyote Jump zeroes coyoteTimerMs immediately so no accidental double-jump occurs.
  • Across a 200-trial human-jitter test (-55ms..+105ms), Production config clears >= 90% vs < 50% for naive 0ms checks.

底层原理与实测基准 · ENGINEERING BREAKDOWN

为什么 AI 默认写法会翻车?实测数据对比

AI 默认生成的 `if is_on_floor() and jump_pressed` 只要玩家晚按 20ms(刚踏出崖边)或落地前早按 40ms 就会直接吞键。在 200 次真实手抖压测中,0ms 零容错的坠崖率高达 78%;开启 110ms 土狼时间 + 120ms 跳跃预输入后,156 次临界输入全部救回且不失精准感。

200 次悬崖手抖压测:0ms 零容错仅 22% 过崖 vs 110ms 土狼时间 + 120ms 预输入达 100% 过崖(救回 156 次吞键)。

多引擎生产代码 · COPY-PASTE READY

Godot 4 (GDScript)、Unity (C#) 与 TypeScript 参考实现

Godot 4 (GDScript)

player_coyote_jump.gd
extends CharacterBody2D

@export var jump_velocity: float = -420.0
@export var gravity: float = 1280.0
@export var coyote_time: float = 0.11       # 110ms post-ledge grace
@export var jump_buffer_time: float = 0.12  # 120ms pre-landing queue

var _coyote_timer: float = 0.0
var _jump_buffer_timer: float = 0.0

func _physics_process(delta: float) -> void:
	if is_on_floor():
		_coyote_timer = coyote_time
	else:
		_coyote_timer = maxf(0.0, _coyote_timer - delta)
		velocity.y += gravity * delta

	if Input.is_action_just_pressed("jump"):
		_jump_buffer_timer = jump_buffer_time
	else:
		_jump_buffer_timer = maxf(0.0, _jump_buffer_timer - delta)

	# Fire jump when BOTH a valid floor/coyote grace and buffered press overlap
	if _jump_buffer_timer > 0.0 and _coyote_timer > 0.0:
		velocity.y = jump_velocity
		_coyote_timer = 0.0
		_jump_buffer_timer = 0.0

	# Variable jump height cut when player releases early
	if Input.is_action_just_released("jump") and velocity.y < 0.0:
		velocity.y *= 0.45

	move_and_slide()

Unity (C#)

CoyoteJumpController.cs
using UnityEngine;

public class CoyoteJumpController : MonoBehaviour
{
    [SerializeField] private Rigidbody2D rb;
    [SerializeField] private float jumpVelocity = 14f;
    [SerializeField] private float coyoteTime = 0.11f;
    [SerializeField] private float jumpBufferTime = 0.12f;

    private float _coyoteCounter;
    private float _jumpBufferCounter;
    public bool IsGrounded { get; set; }

    private void Update()
    {
        _coyoteCounter = IsGrounded ? coyoteTime : Mathf.Max(0f, _coyoteCounter - Time.deltaTime);

        if (Input.GetButtonDown("Jump"))
            _jumpBufferCounter = jumpBufferTime;
        else
            _jumpBufferCounter = Mathf.Max(0f, _jumpBufferCounter - Time.deltaTime);

        if (_jumpBufferCounter > 0f && _coyoteCounter > 0f)
        {
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, jumpVelocity);
            _coyoteCounter = 0f;
            _jumpBufferCounter = 0f;
        }

        if (Input.GetButtonUp("Jump") && rb.linearVelocity.y > 0f)
            rb.linearVelocity = new Vector2(rb.linearVelocity.x, rb.linearVelocity.y * 0.45f);
    }
}

TypeScript (Web / Phaser)

coyote-jump-step.ts
export interface JumpState {
  vy: number;
  grounded: boolean;
  coyoteMs: number;
  bufferMs: number;
}

export function stepCoyoteJump(
  state: JumpState,
  dtMs: number,
  jumpJustPressed: boolean,
  jumpJustReleased: boolean,
  cfg = { coyoteWindowMs: 110, bufferWindowMs: 120, jumpVel: -460 }
): boolean {
  state.coyoteMs = state.grounded ? cfg.coyoteWindowMs : Math.max(0, state.coyoteMs - dtMs);
  state.bufferMs = jumpJustPressed ? cfg.bufferWindowMs : Math.max(0, state.bufferMs - dtMs);

  let jumped = false;
  if (state.bufferMs > 0 && state.coyoteMs > 0) {
    state.vy = cfg.jumpVel;
    state.coyoteMs = 0;
    state.bufferMs = 0;
    jumped = true;
  }
  if (jumpJustReleased && state.vy < 0) state.vy *= 0.45;
  return jumped;
}

开发者高频实战问答 · FAQ

参数调优与工程落地常见问题

2D 平台跳跃游戏的土狼时间(Coyote Time)设多少毫秒最合适?

主流高口碑 2D 平台游戏通常设在 85–130ms(60fps 下约 5–8 帧),《蔚蓝》约 100–110ms。低于 60ms 仍容易吞键,超过 160ms 则会明显穿帮像踩空气。

土狼时间和跳跃预输入如何避免玩家在崖边连按触发二段跳?

起跳瞬间必须把 `_coyote_timer` 和 `_jump_buffer_timer` 同时清零,且只在真正落地 `is_on_floor()` 时重新充能,就能彻底杜绝二段跳漏洞。

Godot 4 里土狼时间应该写在 `_physics_process` 还是 `_process`?

建议在 `_physics_process(delta)` 中推进确定性 60Hz 计时;若追求高刷屏零丢帧,可在 `_input` 里捕获跳跃按下并立刻给 `_jump_buffer_timer` 赋值。

如何让 Claude Code 或 Cursor 自动按这套规范写跳跃控制器?

直接复制上方 `/labs/coyote-time-jump-buffer/skill.md` 一句话提示词发给 Claude Code、Cursor 或 Codex,即可自动套用全部计时器、可变跳高与验收清单。

延伸阅读 · 引擎中心与商业套件

同赛道精选实验台推荐

真实项目提取 · 国风武侠卡牌《招式武林》

每个实验台的数值与代码,都来自正在冲 Steam 的《招式武林》

三名武侠角色、39 种独立机制敌人、70 件宝物、19 招功夫与数百项自动回归测试——我们一边做游戏,一边把踩过的坑提炼成可直接交互的实验台和免费 Skill。