SuperAPI AI Directory

godot-gameplay-developer

Coding & development

View repository

Updated 10-16 19:37

About this skill

Godot Gameplay Development Expert Skill

Important Note: All code examples in this skill are based on Godot 4.5 best practices, using GDScript syntax. Ensure it is used in a Godot 4.x environment to avoid confusion with Godot 3.x syntax.

Skill Overview

godot-gameplay-developer is an intelligent skill specifically for developing Godot game core gameplay, capable of automatically implementing core game mechanics such as character control, physics interaction, game rules, and AI behavior based on the user's natural language descriptions.

Core Features

🎮 Character Control System

  • Movement Control: 2D/3D character movement, jumping, climbing, swimming, etc.
  • State Management: Character state machine (standing, walking, running, jumping, attacking, etc.)
  • Skill System: Implementation of character skills, combos, and special abilities
  • Animation Integration: Seamless integration with AnimationTree/AnimationPlayer

⚛️ Physics System Integration

  • Rigid Body Physics: CharacterBody2D/3D, RigidBody2D/3D control
  • Collision Detection: Precise collision detection and response system
  • Physics Interaction: Physics interactions such as pushing, pulling, throwing, and destroying
  • Environmental Physics: Environmental effects such as fluids, wind, and gravity

🧠 AI Intelligent System

  • Basic AI: Basic behaviors such as patrolling, chasing, and fleeing
  • Decision System: State machine-based AI decision logic
  • Pathfinding: A* pathfinding and navigation system
  • Group Behavior: Advanced AI such as formations and group collaboration

📊 Game Rule Engine

  • Victory Conditions: Diverse settings for game victory conditions
  • Scoring System: Score, level, and achievement systems
  • Game Flow: Control of game pacing such as turn-based and real-time
  • Balance System: Difficulty adjustment and numerical balance

How to Use

Character Control Development

用户: "我想要一个能跳跃、冲刺和二段跳的角色"
系统: 自动实现:
- CharacterBody2D基础控制
- 跳跃物理和二段跳逻辑
- 冲刺技能和冷却系统
- 相应的动画状态机
- 粒子特效集成

Physics Interaction Implementation

用户: "创建一个可以推箱子、拉杠杆的物理谜题"
系统: 智能生成:
- 可推动箱子的物理体
- 杠杆机关机制
- 压力板触发器
- 物理约束和连接
- 谜题完成检测逻辑

AI Behavior Development

用户: "设计一个会巡逻、发现玩家后会追击的守卫AI"
系统: 完整实现:
- 守卫巡逻路径系统
- 视野检测机制
- 追击和丢失目标逻辑
- 警报和协作系统
- AI状态机管理

Game Rule Implementation

用户: "做一个三消游戏,包含连击系统和特殊道具"
系统: 全面开发:
- 三消匹配算法
- 连击计数和奖励系统
- 特殊道具和清除效果
- 分数和等级系统
- 游戏结束条件

Workflow

1. Requirements Analysis

# 分析用户描述
- 提取核心玩法机制
- 识别技术实现要点
- 评估复杂度和依赖关系

2. Architecture Design

# 设计实现架构
- 选择合适的节点类型
- 设计组件通信机制
- 规划数据流向

3. Code Implementation

# 自动生成代码
- 实现核心逻辑
- 集成物理系统
- 配置动画状态
- 添加错误处理

4. Testing and Verification

# 功能测试
- 基础功能验证
- 边界情况测试
- 性能优化建议

MCP Tool Integration

Node Operation Tools

  • create_node - Create game object nodes
  • add_child_node - Add child nodes
  • configure_node - Configure node properties
  • delete_node - Delete nodes

Script Development Tools

  • create_script - Create script files
  • edit_script - Edit script content
  • attach_script - Attach scripts to nodes
  • get_script_content - Get script content

Scene Management Tools

  • create_scene - Create new scenes
  • save_scene - Save scenes
  • load_scene - Load scenes
  • instance_scene - Instantiate scenes

Debugging and Testing Tools

  • play_scene - Run scene tests
  • get_node_properties - Get node properties
  • set_node_property - Set node properties
  • call_node_method - Call node method

Core algorithm library

Movement control algorithms

# 平滑移动算法
func smooth_movement(delta: float) -> void:
    var target_velocity = input_direction * move_speed
    velocity = velocity.lerp(target_velocity, acceleration * delta)
    move_and_slide()

# 跳跃物理算法
func handle_jump() -> void:
    if is_on_floor() and Input.is_action_just_pressed("jump"):
        velocity.y = jump_velocity
        if can_double_jump and jumps_remaining > 0:
            jumps_remaining -= 1

AI decision algorithms

# 状态机AI算法
func update_ai(delta: float) -> void:
    match current_state:
        AIState.PATROL:
            handle_patrol_behavior()
        AIState.CHASE:
            handle_chase_behavior()
        AIState.ATTACK:
            handle_attack_behavior()

Physics interaction algorithms

# 推箱子物理算法
func push_box(box: RigidBody2D, force: Vector2) -> void:
    if can_push_box(box):
        box.apply_central_impulse(force * push_strength)
        play_push_animation()

Game mechanic templates

Platformer mechanics

  • Gravity system: Configurable gravity and fall speed
  • Jump buffering: Coyote time and jump buffer time
  • Wall jump: Wall kick and climbing system
  • Moving platforms: Support for moving and rotating platforms

Combat system mechanics

  • Attack detection: Shape-based attack range detection
  • Damage calculation: Damage system including critical hits and blocking
  • Combo system: Combo count and combo rewards
  • Status effects: Status effects such as poison, freeze, and burn

Puzzle mechanics

  • Switch system: Various types of switches and mechanisms
  • Item interaction: Keys, props, item combinations
  • Environmental interaction: Interactions such as push, pull, activate, and destroy
  • Logic gates: Logical conditions such as AND, OR, and NOT

Racing mechanics

  • Checkpoint system: Track checkpoints and save points
  • Timing system: Precise time and speed calculation
  • Ranking system: Multiplayer ranking and record system
  • Item system: Items such as speed boosts, slows, and shields

Intelligent features

Code optimization

  • Performance optimization: Automatically optimize hot code
  • Memory management: Reasonable object pooling and memory usage
  • Batching: Reduce draw calls and computation

Extensibility

  • Modular design: Easy to add new features
  • Configuration-driven: Adjust parameters through configuration files
  • Event system: Loosely coupled event communication mechanism

Debugging-friendly

  • Detailed logging: Complete debugging information output
  • Visual debugging: Debug line and shape display
  • Performance monitoring: Frame rate and memory usage monitoring

Example implementations

Complete character controller

# 自动生成的角色控制器示例
extends CharacterBody2D
class_name AdvancedCharacterController

@export var move_speed: float = 300.0
@export var jump_velocity: float = -400.0
@export var double_jump_velocity: float = -350.0
@export var dash_speed: float = 600.0
@export var dash_duration: float = 0.2

var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var jumps_remaining: int = 2
var is_dashing: bool = false
var dash_timer: float = 0.0

@onready var animation_tree: AnimationTree = $AnimationTree
@onready var state_machine: AnimationNodeStateMachinePlayback = animation_tree["parameters/playback"]

func _physics_process(delta: float) -> void:
    handle_gravity(delta)
    handle_movement()
    handle_jump()
    handle_dash()
    handle_states()

    move_and_slide()

func handle_gravity(delta: float) -> void:
    if not is_on_floor():
        velocity.y += gravity * delta

func handle_movement() -> void:
    var direction = Input.get_axis("move_left", "move_right")
    velocity.x = direction * move_speed

    if direction != 0:
        state_machine.travel("run")
    else:
        state_machine.travel("idle")

func handle_jump() -> void:
    if Input.is_action_just_pressed("jump"):
        if is_on_floor():
            velocity.y = jump_velocity
            jumps_remaining = 1
        elif jumps_remaining > 0:
            velocity.y = double_jump_velocity
            jumps_remaining = 0
            create_double_jump_effect()

Intelligent AI system

# 自动生成的AI控制器示例
extends Node2D
class_name SmartAIController

enum AIState { PATROL, CHASE, ATTACK, SEARCH, FLEE }

var current_state: AIState = AIState.PATROL

# ✅ 正确:定义状态变化信号
signal state_changed(new_state: AIState, old_state: AIState)
var player: Node2D
var patrol_points: Array[Vector2]
var current_patrol_index: int = 0
var vision_range: float = 200.0
var attack_range: float = 50.0

func _ready() -> void:
    # ✅ 正确:使用延迟调用确保场景树完全准备就绪
    call_deferred("_initialize_player_reference")

func _initialize_player_reference() -> void:
    player = get_tree().get_first_node_in_group("player")
    if not player:
        push_warning("场景中未找到玩家节点,请确保玩家节点在 'player' 组中")

func _process(delta: float) -> void:
    if player:  # ✅ 正确:检查玩家引用是否存在
        update_ai_state()
        execute_current_state(delta)

func update_ai_state() -> void:
    if not player:
        return

    var distance_to_player = global_position.distance_to(player.global_position)
    var can_see_player = can_see_target(player)
    var old_state = current_state

    match current_state:
        AIState.PATROL:
            if can_see_player and distance_to_player <= vision_range:
                current_state = AIState.CHASE
        AIState.CHASE:
            if not can_see_player:
                current_state = AIState.SEARCH
            elif distance_to_player <= attack_range:
                current_state = AIState.ATTACK
        AIState.ATTACK:
            if distance_to_player > attack_range:
                current_state = AIState.CHASE

    # ✅ 正确:状态变化时发射信号,传递新旧状态
    if current_state != old_state:
        state_changed.emit(current_state, old_state)

Quality assurance

Code quality

  • Syntax validation: Ensure code syntax is correct
  • Type checking: Strong typing and type hints
  • Error handling: Comprehensive exception handling mechanism
  • Memory safety: Avoid memory leaks and null pointers

Performance optimization

  • Algorithm optimization: Choose the optimal algorithm implementation
  • Batching optimization: Reduce the number of computations
  • Spatial partitioning: Spatial optimization such as quadtrees and grids
  • LOD system: Level-of-detail optimization

Compatibility

  • Version compatibility: Supports all Godot 4.x versions
  • Platform compatibility: Adaptation for PC, mobile, and console platforms
  • Backward compatibility: Keep the code backward-compatible

Usage limits and precautions

Technical limits

  • Complexity control: Implement highly complex gameplay in stages
  • Performance requirements: High-performance features need additional optimization
  • Platform features: Some platform-specific features require adaptation

Best practices

  • Modular development: Split complex features into small modules
  • Iterative testing: Test and validate each implementation step
  • Complete documentation: Add detailed comments for complex logic

Troubleshooting

Common issues

  1. Unexpected physics behavior: Check physics layers and collision settings
  2. AI freezes: Verify the state machine and navigation system
  3. Performance issues: Analyze hot code paths and memory usage
  4. Animations out of sync: Check animation state-machine configuration

Debugging tips

  • Use the Godot debugger to inspect variables
  • Add visual debugging information
  • Monitor performance metrics
  • Check console errors

Changelog

v1.0.0 (current version)

  • Basic character controller
  • Physics interactions
  • Simple AI behavior
  • Game rules engine

Planned features

  • Advanced AI algorithms
  • Multiplayer synchronization
  • Complex physics simulations
  • Procedural content generation

Skill status: ✅ Available Last updated: 2025-11-09 Compatibility: Godot 4.5+ Dependencies: Godot MCP tools + basic physics knowledge