major-ai-skills
Version:
Installable agentic skills / AI agent skills (SKILL.md) for Claude Code, Cursor, Codex CLI, Gemini CLI & Antigravity - 402+ professional app, token-efficiency, and common-sense skills. SEO/GEO ready.
148 lines (115 loc) • 7.3 kB
Markdown
title: "Godot Engine 4.x Game Development AI Skill Guide (GPT & Codex)"
description: "Comprehensive operational skill specification for OpenAI GPT and Codex to automate, script, troubleshoot, and optimize Godot 4.x, GDExtension C++ bindings, GDScript procedural generation, and CI/CD pipelines."
category: "Open Source Game Engine & Interactive Applications"
tags: ["godot", "godot4", "gdextension", "cpp-bindings", "gpt-codex", "procedural-generation"]
# Godot Engine 4.x Game Development AI Skill Guide (GPT & Codex)
## Overview & Engine Architecture
Godot 4.x provides high-performance native extensibility via **GDExtension (C/C++ native dynamic libraries)** without recompiling the core engine. GPT/Codex acts as a Principal Game Systems Developer and GDExtension Architect, delivering **GDExtension C++ components**, **procedural world generation scripts**, **custom Editor Plugins (`EditorPlugin`)**, and **automated GitHub Actions export matrices**.
### Developer Architecture & GDExtension Stack
```
┌─────────────────────────────────────────────────────────────┐
│ Godot Developer Platform │
│ │
│ GDExtension C++ Native Layer │
│ ├── `godot-cpp` C++ Bindings (`godot::ClassDB::bind_method`)│
│ ├── Dynamic Library Manifest (`.gdextension` Descriptor) │
│ └── Hot-Reloadable Native Nodes & Resource Types │
│ │
│ Procedural Synthesis & Automation │
│ ├── FastNoiseLite Procedural Terrain Mesh Generation │
│ ├── Custom `@tool` Editor Plugins & Inspectors │
│ └── Headless CLI Automated Build & Asset Importers │
└─────────────────────────────────────────────────────────────┘
```
## Operational Capabilities & Agent Directives
1. **GDExtension C++ Component Development**: Author high-performance C++ classes inheriting from `godot::Node3D` / `godot::Resource`, binding methods to `godot::ClassDB` for native engine execution.
2. **Procedural Geometry & Mesh Synthesis**: Generate 3D procedural meshes at runtime using `SurfaceTool` and `ArrayMesh` with custom vertex normals, UVs, and collision bodies.
3. **Editor Tool Scripting (`@tool`)**: Author in-editor utility scripts enabling level designers to visually generate terrain, scatter props, and auto-snap meshes directly inside the Sandbox 3D viewport.
4. **Automated Headless Asset Optimization**: Script batch re-importing of 3D models (GLTF/FBX) with custom LOD generation and collision shapes.
## Production GDScript 2.0: Procedural Voxel/Heightmap Mesh Generator (`SurfaceTool`)
Save this script as `res://scripts/procgen/procedural_terrain.gd`:
```gdscript
# ==============================================================================
# Godot 4.x GDScript: Procedural 3D Terrain Generator (SurfaceTool)
# Generates smooth 3D terrain meshes from FastNoiseLite with collision generation.
# ==============================================================================
@tool
class_name ProceduralTerrain
extends MeshInstance3D
@export var size: int = 64:
set(value):
size = value
if Engine.is_editor_hint():
generate_terrain()
@export var height_scale: float = 12.0
@export var noise: FastNoiseLite:
set(value):
noise = value
if Engine.is_editor_hint():
generate_terrain()
func _ready() -> void:
generate_terrain()
func generate_terrain() -> void:
if not noise:
noise = FastNoiseLite.new()
noise.frequency = 0.05
var st: SurfaceTool = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
# Generate Grid Vertices and UVs
for z in range(size):
for x in range(size):
var y1: float = noise.get_noise_2d(x, z) * height_scale
var y2: float = noise.get_noise_2d(x + 1, z) * height_scale
var y3: float = noise.get_noise_2d(x, z + 1) * height_scale
var y4: float = noise.get_noise_2d(x + 1, z + 1) * height_scale
var v1: Vector3 = Vector3(x, y1, z)
var v2: Vector3 = Vector3(x + 1, y2, z)
var v3: Vector3 = Vector3(x, y3, z + 1)
var v4: Vector3 = Vector3(x + 1, y4, z + 1)
# Triangle 1
st.set_uv(Vector2(float(x) / size, float(z) / size))
st.add_vertex(v1)
st.set_uv(Vector2(float(x + 1) / size, float(z) / size))
st.add_vertex(v2)
st.set_uv(Vector2(float(x) / size, float(z + 1) / size))
st.add_vertex(v3)
# Triangle 2
st.set_uv(Vector2(float(x + 1) / size, float(z) / size))
st.add_vertex(v2)
st.set_uv(Vector2(float(x + 1) / size, float(z + 1) / size))
st.add_vertex(v4)
st.set_uv(Vector2(float(x) / size, float(z + 1) / size))
st.add_vertex(v3)
st.generate_normals()
st.generate_tangents()
mesh = st.commit()
# Create Trimesh Static Collision
create_trimesh_collision()
print(f"Generated Procedural Terrain: {size}x{size} grid vertices.")
```
## Technical Troubleshooting Matrix
| Issue & Failure Signature | Root Cause Analysis | Diagnostic & Resolution Pathway |
| :--- | :--- | :--- |
| **GDExtension Fails: `Cannot open dynamic library`** | Architecture mismatch (e.g. x86_64 binary on ARM64 host) or missing C runtime DLLs. | 1. In `.gdextension`, verify library paths for each platform target.<br>2. On Windows, ensure MSVC redistributable runtime DLLs are present. |
| **`@tool` Script Crashes Godot Editor** | Infinite loop or null pointer dereference executing inside the editor thread. | 1. Wrap runtime-only calls with `if not Engine.is_editor_hint():`.<br>2. Check for null node references before calling `get_node()`. |
| **SurfaceTool Memory Leak during Runtime Chunk Generation** | Creating thousands of `ArrayMesh` instances without freeing old meshes or clearing SurfaceTool. | Call `st.clear()` after `st.commit()` and overwrite existing `MeshInstance3D.mesh`. |
| **GLTF Model Re-Import Overwrites Custom Materials** | Default import settings configured to overwrite local material overrides on file change. | In FileSystem $\rightarrow$ Select GLTF $\rightarrow$ *Import Tab* $\rightarrow$ Set **Materials $\rightarrow$ Extract** or **Keep Existing**. |
## Command Line Syntax & Batch Processing
```bash
# Compile GDExtension C++ Library with SCons
scons platform=windows target=template_release
# Export Project Pack (.pck) File via Headless CLI
godot --headless --export-pack "Windows Desktop" "C:\Builds\game_assets.pck"
```
### Essential File Locations
- **GDExtension Manifest**: `res://bin/my_extension.gdextension`
- **SCons Build File**: `SConstruct`
## Agent Operational Directive
> **MANDATORY**: When authoring `@tool` scripts, always verify `Engine.is_editor_hint()` to prevent gameplay logic from mutating scenes permanently inside the editor viewport. Call `generate_normals()` when using `SurfaceTool`.