input-patterns
БесплатноБез исполняемых скриптовНе проверенGame input code patterns: Godot InputMap actions, a scaled radial deadzone, jump buffer with coyote time, rebinding serialization, a mobile virtual joystick…
от HermeticOrmus★ 83 звезды на GitHubОб этом скилле
Input Patterns
Godot InputMap Action Configuration
# Define input actions programmatically (useful for testing/CI or runtime setup)
# Normally done in Project Settings > InputMap, but here for reference:
func _setup_default_bindings() -> void:
# Movement actions
_add_action_with_keys(&"move_forward", KEY_W, JOY_BUTTON_INVALID, -1, JOY_AXIS_LEFT_Y)
_add_action_with_keys(&"move_back", KEY_S, JOY_BUTTON_INVALID, 1, JOY_AXIS_LEFT_Y)
_add_action_with_keys(&"move_left", KEY_A, JOY_BUTTON_INVALID, -1, JOY_AXIS_LEFT_X)
_add_action_with_keys(&"move_right", KEY_D, JOY_BUTTON_INVALID, 1, JOY_AXIS_LEFT_X)
_add_action_with_keys(&"jump", KEY_SPACE, JOY_BUTTON_A, 0.0, -1)
_add_action_with_keys(&"interact", KEY_E, JOY_BUTTON_X, 0.0, -1)
func _add_action_with_keys(
action: StringName,
key: Key,
joy_button: JoyButton,
axis_value: float = 0.0,
joy_axis: JoyAxis = JOY_AXIS_INVALID
) -> void:
if not InputMap.has_action(action):
InputMap.add_action(action, 0.15) # 0.15 = deadzone for this action
if key != KEY_NONE:
var key_event := InputEventKey.new()
key_event.keycode = key
InputMap.action_add_event(action, key_event)
if joy_button != JOY_BUTTON_INVALID:
var button_event := InputEventJoypadButton.new()
button_event.button_index = joy_button
InputMap.action_add_event(action, button_event)
Scaled Radial Deadzone
# Correctly apply radial deadzone with remapping
class_name InputDeadzone
static func apply_radial(raw: Vector2, inner: float = 0.15, outer: float = 0.95) -> Vector2:
var magnitude := raw.length()
if magnitude < inner:
return Vector2.ZERO
if magnitude > outer:
return raw.normalized()
# Remap [inner, outer] -> [0, 1] for smooth transition
var remapped := (magnitude - inner) / (outer - inner)
return raw.normalized() * remapped
# Usage in character controller:
func _physics_process(_delta: float) -> void:
var raw := Input.get_vector(&"move_left", &"move_right", &"move_forward", &"move_back")
var input := InputDeadzone.apply_radial(raw)
# input is now clean with no dead zone artifact
Input Buffering (Jump Buffer + Coyote Time)
class_name PlatformerInput extends Node
const JUMP_BUFFER_FRAMES: int = 8 # frames to remember jump input
const COYOTE_FRAMES: int = 6 # frames after leaving platform to still jump
var _jump_buffer: int = 0 # frames remaining in jump buffer
var _coyote_timer: int = 0 # frames remaining in coyote time
var _was_on_floor: bool = false
@onready var body: CharacterBody3D = get_parent()
func _physics_process(_delta: float) -> void:
_update_coyote_time()
_update_jump_buffer()
func _update_coyote_time() -> void:
if body.is_on_floor():
_coyote_timer = COYOTE_FRAMES
_was_on_floor = true
elif _was_on_floor:
_coyote_timer = max(0, _coyote_timer - 1)
func _update_jump_buffer() -> void:
if Input.is_action_just_pressed(&"jump"):
_jump_buffer = JUMP_BUFFER_FRAMES
elif _jump_buffer > 0:
_jump_buffer -= 1
func consume_jump() -> bool:
# Returns true if a buffered jump should execute
if _jump_buffer > 0 and _coyote_timer > 0:
_jump_buffer = 0
_coyote_timer = 0
_was_on_floor = false
return true
return false
Input Rebinding Serialization
class_name InputRebinder extends Node
const SAVE_PATH := "user://input_bindings.cfg"
var _default_bindings: Dictionary = {}
func _ready() -> void:
# Cache defaults at startup before any user changes
for action in InputMap.get_actions():
if not action.begins_with("ui_"): # Skip UI actions
_default_bindings[action] = InputMap.action_get_events(action).duplicate()
func save_bindings() -> void:
var config := ConfigFile.new()
for action in InputMap.get_actions():
if action.begins_with("ui_"):
continue
var events := InputMap.action_get_events(action)
var event_data: Array[Dictionary] = []
for event in events:
event_data.append(_serialize_event(event))
config.set_value("bindings", action, event_data)
config.save(SAVE_PATH)
func load_bindings() -> void:
var config := ConfigFile.new()
if config.load(SAVE_PATH) != OK:
return
for action in config.get_section_keys("bindings"):
var event_data: Array = config.get_value("bindings", action, [])
InputMap.action_erase_events(action)
for data in event_data:
var event := _deserialize_event(data)
if event:
InputMap.action_add_event(action, event)
func reset_to_defaults() -> void:
for action in _default_bindings:
InputMap.action_erase_events(action)
for event in _default_bindings[action]:
InputMap.action_add_event(action, eve
Установить input-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл input-patterns?
Game input code patterns: Godot InputMap actions, a scaled radial deadzone, jump buffer with coyote time, rebinding serialization, a mobile virtual joystick, and gamepad rumble. Use when implementing controls, remapping, or controller feel.
Как установить скилл input-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл input-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic