@jarrodmedrano/claude-skills 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/bevy/SKILL.md +406 -0
- package/.claude/skills/bevy/references/bevy_specific_tips.md +385 -0
- package/.claude/skills/bevy/references/common_pitfalls.md +217 -0
- package/.claude/skills/bevy/references/ecs_patterns.md +277 -0
- package/.claude/skills/bevy/references/project_structure.md +116 -0
- package/.claude/skills/bevy/references/ui_development.md +147 -0
- package/.claude/skills/domain-driven-design/SKILL.md +459 -0
- package/.claude/skills/domain-driven-design/references/ddd_foundations_and_patterns.md +664 -0
- package/.claude/skills/domain-driven-design/references/rich_hickey_principles.md +406 -0
- package/.claude/skills/domain-driven-design/references/visualization_examples.md +790 -0
- package/.claude/skills/domain-driven-design/references/wlaschin_patterns.md +639 -0
- package/.claude/skills/godot/SKILL.md +728 -0
- package/.claude/skills/godot/assets/templates/attribute_template.gd +109 -0
- package/.claude/skills/godot/assets/templates/component_template.gd +76 -0
- package/.claude/skills/godot/assets/templates/interaction_template.gd +108 -0
- package/.claude/skills/godot/assets/templates/item_resource.tres +11 -0
- package/.claude/skills/godot/assets/templates/spell_resource.tres +20 -0
- package/.claude/skills/godot/references/architecture-patterns.md +608 -0
- package/.claude/skills/godot/references/common-pitfalls.md +518 -0
- package/.claude/skills/godot/references/file-formats.md +491 -0
- package/.claude/skills/godot/references/godot4-physics-api.md +302 -0
- package/.claude/skills/godot/scripts/validate_tres.py +145 -0
- package/.claude/skills/godot/scripts/validate_tscn.py +170 -0
- package/.claude/skills/guitar-fretboard-mastery/SKILL.md +179 -0
- package/.claude/skills/guitar-fretboard-mastery/guitar-fretboard-mastery.skill +0 -0
- package/.claude/skills/react-three-fiber/SKILL.md +2055 -0
- package/.claude/skills/react-three-fiber/scripts/build-scene.ts +171 -0
- package/package.json +1 -1
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: godot
|
|
3
|
+
description: This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Godot Engine Development Skill
|
|
7
|
+
|
|
8
|
+
Specialized guidance for developing games and applications with Godot Engine, with emphasis on effective collaboration between LLM coding assistants and Godot's unique file structure.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Godot projects use a mix of GDScript code files (.gd) and text-based resource files (.tscn for scenes, .tres for resources). While GDScript is straightforward, the resource files have strict formatting requirements that differ significantly from GDScript syntax. This skill provides file format expertise, proven architecture patterns, validation tools, code templates, and debugging workflows to enable effective development of Godot projects.
|
|
13
|
+
|
|
14
|
+
## When to Use This Skill
|
|
15
|
+
|
|
16
|
+
Invoke this skill when:
|
|
17
|
+
|
|
18
|
+
- Working on any Godot Engine project
|
|
19
|
+
- Creating or modifying .tscn (scene) or .tres (resource) files
|
|
20
|
+
- Implementing game systems (interactions, attributes, spells, inventory, etc.)
|
|
21
|
+
- Debugging "file failed to load" or similar resource errors
|
|
22
|
+
- Setting up component-based architectures
|
|
23
|
+
- Creating signal-driven systems
|
|
24
|
+
- Implementing resource-based data (items, spells, abilities)
|
|
25
|
+
|
|
26
|
+
## Key Principles
|
|
27
|
+
|
|
28
|
+
### 1. Understand File Format Differences
|
|
29
|
+
|
|
30
|
+
**GDScript (.gd) - Full Programming Language:**
|
|
31
|
+
```gdscript
|
|
32
|
+
extends Node
|
|
33
|
+
class_name MyClass
|
|
34
|
+
|
|
35
|
+
var speed: float = 5.0
|
|
36
|
+
const MAX_HEALTH = 100
|
|
37
|
+
|
|
38
|
+
func _ready():
|
|
39
|
+
print("Ready")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Scene Files (.tscn) - Strict Serialization Format:**
|
|
43
|
+
```
|
|
44
|
+
[ext_resource type="Script" path="res://script.gd" id="1"]
|
|
45
|
+
|
|
46
|
+
[node name="Player" type="CharacterBody3D"]
|
|
47
|
+
script = ExtResource("1") # NOT preload()!
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Resource Files (.tres) - NO GDScript Syntax:**
|
|
51
|
+
```
|
|
52
|
+
[ext_resource type="Script" path="res://item.gd" id="1"]
|
|
53
|
+
|
|
54
|
+
[resource]
|
|
55
|
+
script = ExtResource("1") # NOT preload()!
|
|
56
|
+
item_name = "Sword" # NOT var item_name = "Sword"!
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2. Critical Rules for .tres and .tscn Files
|
|
60
|
+
|
|
61
|
+
**NEVER use in .tres/.tscn files:**
|
|
62
|
+
- `preload()` - Use `ExtResource("id")` instead
|
|
63
|
+
- `var`, `const`, `func` - These are GDScript keywords
|
|
64
|
+
- Untyped arrays - Use `Array[Type]([...])` syntax
|
|
65
|
+
|
|
66
|
+
**ALWAYS use in .tres/.tscn files:**
|
|
67
|
+
- `ExtResource("id")` for external resources
|
|
68
|
+
- `SubResource("id")` for inline resources
|
|
69
|
+
- Typed arrays: `Array[Resource]([...])`
|
|
70
|
+
- Proper ExtResource declarations before use
|
|
71
|
+
|
|
72
|
+
### 3. Separation of Concerns
|
|
73
|
+
|
|
74
|
+
**Keep logic in .gd files, data in .tres files:**
|
|
75
|
+
```
|
|
76
|
+
src/
|
|
77
|
+
spells/
|
|
78
|
+
spell_resource.gd # Class definition + logic
|
|
79
|
+
spell_effect.gd # Effect logic
|
|
80
|
+
resources/
|
|
81
|
+
spells/
|
|
82
|
+
fireball.tres # Data only, references scripts
|
|
83
|
+
ice_spike.tres # Data only
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This makes LLM editing much safer and clearer.
|
|
87
|
+
|
|
88
|
+
### 4. Component-Based Architecture
|
|
89
|
+
|
|
90
|
+
Break functionality into small, focused components:
|
|
91
|
+
```
|
|
92
|
+
Player (CharacterBody3D)
|
|
93
|
+
├─ HealthAttribute (Node) # Component
|
|
94
|
+
├─ ManaAttribute (Node) # Component
|
|
95
|
+
├─ Inventory (Node) # Component
|
|
96
|
+
└─ StateMachine (Node) # Component
|
|
97
|
+
├─ IdleState (Node)
|
|
98
|
+
├─ MoveState (Node)
|
|
99
|
+
└─ AttackState (Node)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Benefits:**
|
|
103
|
+
- Each component is a small, focused file
|
|
104
|
+
- Easy to understand and modify
|
|
105
|
+
- Clear responsibilities
|
|
106
|
+
- Reusable across different entities
|
|
107
|
+
|
|
108
|
+
### 5. Signal-Driven Communication
|
|
109
|
+
|
|
110
|
+
Use signals for loose coupling:
|
|
111
|
+
```gdscript
|
|
112
|
+
# Component emits signals
|
|
113
|
+
signal health_changed(current, max)
|
|
114
|
+
signal death()
|
|
115
|
+
|
|
116
|
+
# Parent connects to signals
|
|
117
|
+
func _ready():
|
|
118
|
+
$HealthAttribute.health_changed.connect(_on_health_changed)
|
|
119
|
+
$HealthAttribute.death.connect(_on_death)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Benefits:**
|
|
123
|
+
- No tight coupling between systems
|
|
124
|
+
- Easy to add new listeners
|
|
125
|
+
- Self-documenting (signals show available events)
|
|
126
|
+
- UI can connect without modifying game logic
|
|
127
|
+
|
|
128
|
+
## Using Bundled Resources
|
|
129
|
+
|
|
130
|
+
### Validation Scripts
|
|
131
|
+
|
|
132
|
+
Validate .tres and .tscn files before testing in Godot to catch syntax errors early.
|
|
133
|
+
|
|
134
|
+
**Validate .tres file:**
|
|
135
|
+
```bash
|
|
136
|
+
python3 scripts/validate_tres.py resources/spells/fireball.tres
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Validate .tscn file:**
|
|
140
|
+
```bash
|
|
141
|
+
python3 scripts/validate_tscn.py scenes/player/player.tscn
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Use these scripts when:
|
|
145
|
+
- After creating or editing .tres/.tscn files programmatically
|
|
146
|
+
- When debugging "failed to load" errors
|
|
147
|
+
- Before committing scene/resource changes
|
|
148
|
+
- When user reports issues with custom resources
|
|
149
|
+
|
|
150
|
+
### Reference Documentation
|
|
151
|
+
|
|
152
|
+
Load reference files when needed for detailed information:
|
|
153
|
+
|
|
154
|
+
**`references/file-formats.md`** - Deep dive into .gd, .tscn, .tres syntax:
|
|
155
|
+
- Complete syntax rules for each file type
|
|
156
|
+
- Common mistakes with examples
|
|
157
|
+
- Safe vs risky editing patterns
|
|
158
|
+
- ExtResource and SubResource usage
|
|
159
|
+
|
|
160
|
+
**`references/architecture-patterns.md`** - Proven architectural patterns:
|
|
161
|
+
- Component-based interaction system
|
|
162
|
+
- Attribute system (health, mana, etc.)
|
|
163
|
+
- Resource-based effect system (spells, items)
|
|
164
|
+
- Inventory system
|
|
165
|
+
- State machine pattern
|
|
166
|
+
- Examples of combining patterns
|
|
167
|
+
|
|
168
|
+
Read these references when:
|
|
169
|
+
- Implementing new game systems
|
|
170
|
+
- Unsure about .tres/.tscn syntax
|
|
171
|
+
- Debugging file format errors
|
|
172
|
+
- Planning architecture for new features
|
|
173
|
+
|
|
174
|
+
### Code Templates
|
|
175
|
+
|
|
176
|
+
Use templates as starting points for common patterns. Templates are in `assets/templates/`:
|
|
177
|
+
|
|
178
|
+
**`component_template.gd`** - Base component with signals, exports, activation:
|
|
179
|
+
```gdscript
|
|
180
|
+
# Copy and customize for new components
|
|
181
|
+
cp assets/templates/component_template.gd src/components/my_component.gd
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**`attribute_template.gd`** - Numeric attribute (health, mana, stamina):
|
|
185
|
+
```gdscript
|
|
186
|
+
# Use for any numeric attribute with min/max
|
|
187
|
+
cp assets/templates/attribute_template.gd src/attributes/stamina_attribute.gd
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**`interaction_template.gd`** - Interaction component base class:
|
|
191
|
+
```gdscript
|
|
192
|
+
# Extend for custom interactions (pickup, door, switch, etc.)
|
|
193
|
+
cp assets/templates/interaction_template.gd src/interactions/lever_interaction.gd
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**`spell_resource.tres`** - Example spell with effects:
|
|
197
|
+
```bash
|
|
198
|
+
# Use as reference for creating new spell data
|
|
199
|
+
cat assets/templates/spell_resource.tres
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**`item_resource.tres`** - Example item resource:
|
|
203
|
+
```bash
|
|
204
|
+
# Use as reference for creating new item data
|
|
205
|
+
cat assets/templates/item_resource.tres
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Workflows
|
|
209
|
+
|
|
210
|
+
### Workflow 1: Creating a New Component System
|
|
211
|
+
|
|
212
|
+
Example: Adding a health system to enemies.
|
|
213
|
+
|
|
214
|
+
**Steps:**
|
|
215
|
+
|
|
216
|
+
1. **Read architecture patterns reference:**
|
|
217
|
+
```bash
|
|
218
|
+
# Check for similar patterns
|
|
219
|
+
Read references/architecture-patterns.md
|
|
220
|
+
# Look for "Attribute System" section
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
2. **Create base class using template:**
|
|
224
|
+
```bash
|
|
225
|
+
cp assets/templates/attribute_template.gd src/attributes/attribute.gd
|
|
226
|
+
# Customize the base class
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
3. **Create specialized subclass:**
|
|
230
|
+
```bash
|
|
231
|
+
# Create health_attribute.gd extending attribute.gd
|
|
232
|
+
# Add health-specific signals (damage_taken, death)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
4. **Add to scene via .tscn edit:**
|
|
236
|
+
```
|
|
237
|
+
[ext_resource type="Script" path="res://src/attributes/health_attribute.gd" id="4_health"]
|
|
238
|
+
|
|
239
|
+
[node name="HealthAttribute" type="Node" parent="Enemy"]
|
|
240
|
+
script = ExtResource("4_health")
|
|
241
|
+
value_max = 50.0
|
|
242
|
+
value_start = 50.0
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
5. **Test immediately in Godot editor**
|
|
246
|
+
|
|
247
|
+
6. **If issues, validate the scene file:**
|
|
248
|
+
```bash
|
|
249
|
+
python3 scripts/validate_tscn.py scenes/enemies/base_enemy.tscn
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Workflow 2: Creating Resource Data Files (.tres)
|
|
253
|
+
|
|
254
|
+
Example: Creating a new spell.
|
|
255
|
+
|
|
256
|
+
**Steps:**
|
|
257
|
+
|
|
258
|
+
1. **Reference the template:**
|
|
259
|
+
```bash
|
|
260
|
+
cat assets/templates/spell_resource.tres
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
2. **Create new .tres file with proper structure:**
|
|
264
|
+
```tres
|
|
265
|
+
[gd_resource type="Resource" script_class="SpellResource" load_steps=3 format=3]
|
|
266
|
+
|
|
267
|
+
[ext_resource type="Script" path="res://src/spells/spell_resource.gd" id="1"]
|
|
268
|
+
[ext_resource type="Script" path="res://src/spells/spell_effect.gd" id="2"]
|
|
269
|
+
|
|
270
|
+
[sub_resource type="Resource" id="Effect_1"]
|
|
271
|
+
script = ExtResource("2")
|
|
272
|
+
effect_type = 0
|
|
273
|
+
magnitude_min = 15.0
|
|
274
|
+
magnitude_max = 25.0
|
|
275
|
+
|
|
276
|
+
[resource]
|
|
277
|
+
script = ExtResource("1")
|
|
278
|
+
spell_name = "Fireball"
|
|
279
|
+
spell_id = "fireball"
|
|
280
|
+
mana_cost = 25.0
|
|
281
|
+
effects = Array[ExtResource("2")]([SubResource("Effect_1")])
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
3. **Validate before testing:**
|
|
285
|
+
```bash
|
|
286
|
+
python3 scripts/validate_tres.py resources/spells/fireball.tres
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
4. **Fix any errors reported by validator**
|
|
290
|
+
|
|
291
|
+
5. **Test in Godot editor**
|
|
292
|
+
|
|
293
|
+
### Workflow 3: Debugging Resource Loading Issues
|
|
294
|
+
|
|
295
|
+
When user reports "resource failed to load" or similar errors.
|
|
296
|
+
|
|
297
|
+
**Steps:**
|
|
298
|
+
|
|
299
|
+
1. **Read the file reported in error:**
|
|
300
|
+
```bash
|
|
301
|
+
# Check file syntax
|
|
302
|
+
Read resources/spells/problem_spell.tres
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
2. **Run validation script:**
|
|
306
|
+
```bash
|
|
307
|
+
python3 scripts/validate_tres.py resources/spells/problem_spell.tres
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
3. **Check for common mistakes:**
|
|
311
|
+
- Using `preload()` instead of `ExtResource()`
|
|
312
|
+
- Using `var`, `const`, `func` keywords
|
|
313
|
+
- Missing ExtResource declarations
|
|
314
|
+
- Incorrect array syntax (not typed)
|
|
315
|
+
|
|
316
|
+
4. **Read file format reference if needed:**
|
|
317
|
+
```bash
|
|
318
|
+
Read references/file-formats.md
|
|
319
|
+
# Focus on "Resource Files (.tres)" section
|
|
320
|
+
# Check "Common Mistakes Reference"
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
5. **Fix errors and re-validate**
|
|
324
|
+
|
|
325
|
+
### Workflow 4: Implementing from Architecture Patterns
|
|
326
|
+
|
|
327
|
+
When implementing a known pattern (interaction system, state machine, etc.).
|
|
328
|
+
|
|
329
|
+
**Steps:**
|
|
330
|
+
|
|
331
|
+
1. **Read the relevant pattern:**
|
|
332
|
+
```bash
|
|
333
|
+
Read references/architecture-patterns.md
|
|
334
|
+
# Find the specific pattern (e.g., "Component-Based Interaction System")
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
2. **Copy relevant template:**
|
|
338
|
+
```bash
|
|
339
|
+
cp assets/templates/interaction_template.gd src/interactions/door_interaction.gd
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
3. **Customize the template:**
|
|
343
|
+
- Override `_perform_interaction()`
|
|
344
|
+
- Add custom exports for configuration
|
|
345
|
+
- Add custom signals if needed
|
|
346
|
+
|
|
347
|
+
4. **Create scene structure following pattern:**
|
|
348
|
+
```
|
|
349
|
+
[node name="Door" type="StaticBody3D"]
|
|
350
|
+
script = ExtResource("base_interactable.gd")
|
|
351
|
+
|
|
352
|
+
[node name="DoorInteraction" type="Node" parent="."]
|
|
353
|
+
script = ExtResource("door_interaction.gd")
|
|
354
|
+
interaction_text = "Open Door"
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
5. **Test incrementally**
|
|
358
|
+
|
|
359
|
+
## Common Pitfalls and Solutions
|
|
360
|
+
|
|
361
|
+
### Pitfall 1: Using GDScript Syntax in .tres Files
|
|
362
|
+
|
|
363
|
+
**Problem:**
|
|
364
|
+
```tres
|
|
365
|
+
# ❌ WRONG
|
|
366
|
+
script = preload("res://script.gd")
|
|
367
|
+
var items = [1, 2, 3]
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Solution:**
|
|
371
|
+
```tres
|
|
372
|
+
# ✅ CORRECT
|
|
373
|
+
[ext_resource type="Script" path="res://script.gd" id="1"]
|
|
374
|
+
script = ExtResource("1")
|
|
375
|
+
items = Array[int]([1, 2, 3])
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Prevention:** Run validation script before testing.
|
|
379
|
+
|
|
380
|
+
### Pitfall 2: Missing ExtResource Declarations
|
|
381
|
+
|
|
382
|
+
**Problem:**
|
|
383
|
+
```tres
|
|
384
|
+
[resource]
|
|
385
|
+
script = ExtResource("1_script") # Not declared!
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**Solution:**
|
|
389
|
+
```tres
|
|
390
|
+
[ext_resource type="Script" path="res://script.gd" id="1_script"]
|
|
391
|
+
|
|
392
|
+
[resource]
|
|
393
|
+
script = ExtResource("1_script")
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**Detection:** Validation script will catch this.
|
|
397
|
+
|
|
398
|
+
### Pitfall 3: Editing Complex .tscn Hierarchies
|
|
399
|
+
|
|
400
|
+
**Problem:** Modifying instanced scene children can break when editor re-saves.
|
|
401
|
+
|
|
402
|
+
**Solution:**
|
|
403
|
+
- Make only simple property edits in .tscn files
|
|
404
|
+
- For complex changes, use Godot editor
|
|
405
|
+
- Test immediately after text edits
|
|
406
|
+
- Use git to track changes and revert if needed
|
|
407
|
+
|
|
408
|
+
### Pitfall 4: Untyped Arrays in .tres Files
|
|
409
|
+
|
|
410
|
+
**Problem:**
|
|
411
|
+
```tres
|
|
412
|
+
effects = [SubResource("Effect_1")] # Missing type
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Solution:**
|
|
416
|
+
```tres
|
|
417
|
+
effects = Array[Resource]([SubResource("Effect_1")])
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Prevention:** Validation script warns about this.
|
|
421
|
+
|
|
422
|
+
### Pitfall 5: Forgetting Instance Property Overrides
|
|
423
|
+
|
|
424
|
+
**Problem:** When instancing a scene, forgetting to override child node properties. The instance uses default values (often `null`), causing silent bugs.
|
|
425
|
+
|
|
426
|
+
```
|
|
427
|
+
# level.tscn
|
|
428
|
+
[node name="KeyPickup" parent="." instance=ExtResource("6_pickup")]
|
|
429
|
+
# Oops! PickupInteraction.item_resource is null - pickup won't work!
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Solution:** Always configure instanced scene properties using the `index` syntax:
|
|
433
|
+
|
|
434
|
+
```
|
|
435
|
+
[node name="KeyPickup" parent="." instance=ExtResource("6_pickup")]
|
|
436
|
+
|
|
437
|
+
[node name="PickupInteraction" parent="KeyPickup" index="0"]
|
|
438
|
+
item_resource = ExtResource("7_key")
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
**Detection:**
|
|
442
|
+
- Test the instance in-game immediately
|
|
443
|
+
- Read `references/file-formats.md` "Instance Property Overrides" section for details
|
|
444
|
+
- When creating scene instances, ask: "Does this scene have configurable components that need properties set?"
|
|
445
|
+
|
|
446
|
+
**Prevention:** After instancing any scene with configurable children (PickupInteraction, DoorInteraction, etc.), always verify critical properties are overridden.
|
|
447
|
+
|
|
448
|
+
### Pitfall 6: CPUParticles3D color_ramp Not Displaying Colors
|
|
449
|
+
|
|
450
|
+
**Problem:** Setting `color_ramp` on CPUParticles3D, but particles still appear white or don't show the gradient colors.
|
|
451
|
+
|
|
452
|
+
```tres
|
|
453
|
+
[node name="CPUParticles3D" type="CPUParticles3D" parent="."]
|
|
454
|
+
mesh = SubResource("SphereMesh_1")
|
|
455
|
+
color_ramp = SubResource("Gradient_1") # Gradient is set but doesn't work!
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**Root Cause:** The mesh needs a material with `vertex_color_use_as_albedo = true` to apply particle colors to the mesh surface.
|
|
459
|
+
|
|
460
|
+
**Solution:** Add a StandardMaterial3D to the mesh with vertex color enabled:
|
|
461
|
+
|
|
462
|
+
```tres
|
|
463
|
+
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1"]
|
|
464
|
+
vertex_color_use_as_albedo = true
|
|
465
|
+
|
|
466
|
+
[sub_resource type="SphereMesh" id="SphereMesh_1"]
|
|
467
|
+
material = SubResource("StandardMaterial3D_1")
|
|
468
|
+
radius = 0.12
|
|
469
|
+
height = 0.24
|
|
470
|
+
|
|
471
|
+
[node name="CPUParticles3D" type="CPUParticles3D" parent="."]
|
|
472
|
+
mesh = SubResource("SphereMesh_1")
|
|
473
|
+
color_ramp = SubResource("Gradient_1") # Now works!
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
**Prevention:** When creating CPUParticles3D with `color` or `color_ramp`, always add a material with `vertex_color_use_as_albedo = true` to the mesh.
|
|
477
|
+
|
|
478
|
+
## Best Practices
|
|
479
|
+
|
|
480
|
+
### 1. Consult References for Common Issues
|
|
481
|
+
|
|
482
|
+
When encountering issues, consult the reference documentation:
|
|
483
|
+
|
|
484
|
+
**`references/common-pitfalls.md`** - Common Godot gotchas and solutions:
|
|
485
|
+
- Initialization and @onready timing issues
|
|
486
|
+
- Node reference and get_node() problems
|
|
487
|
+
- Signal connection issues
|
|
488
|
+
- Resource loading and modification
|
|
489
|
+
- CharacterBody3D movement
|
|
490
|
+
- Transform and basis confusion
|
|
491
|
+
- Input handling
|
|
492
|
+
- Type safety issues
|
|
493
|
+
- Scene instancing pitfalls
|
|
494
|
+
- Tween issues
|
|
495
|
+
|
|
496
|
+
**`references/godot4-physics-api.md`** - Physics API quick reference:
|
|
497
|
+
- Correct raycast API (`PhysicsRayQueryParameters3D`)
|
|
498
|
+
- Shape queries and collision detection
|
|
499
|
+
- Collision layers and masks
|
|
500
|
+
- Area3D vs RigidBody3D vs CharacterBody3D
|
|
501
|
+
- Common physics patterns
|
|
502
|
+
- Performance tips
|
|
503
|
+
|
|
504
|
+
Load these when:
|
|
505
|
+
- Getting null reference errors
|
|
506
|
+
- Implementing physics/collision systems
|
|
507
|
+
- Debugging timing issues with @onready
|
|
508
|
+
- Working with CharacterBody3D movement
|
|
509
|
+
- Setting up raycasts or shape queries
|
|
510
|
+
|
|
511
|
+
### 2. Always Validate After Editing .tres/.tscn
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
python3 scripts/validate_tres.py path/to/file.tres
|
|
515
|
+
python3 scripts/validate_tscn.py path/to/file.tscn
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### 2. Use Templates as Starting Points
|
|
519
|
+
|
|
520
|
+
Don't write components from scratch - adapt templates:
|
|
521
|
+
```bash
|
|
522
|
+
cp assets/templates/component_template.gd src/my_component.gd
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### 3. Read References for Detailed Syntax
|
|
526
|
+
|
|
527
|
+
When unsure about syntax, load the reference:
|
|
528
|
+
```bash
|
|
529
|
+
Read references/file-formats.md
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### 4. Follow Separation of Concerns
|
|
533
|
+
|
|
534
|
+
- Logic → .gd files
|
|
535
|
+
- Data → .tres files
|
|
536
|
+
- Scene structure → .tscn files (prefer editor for complex changes)
|
|
537
|
+
|
|
538
|
+
### 5. Use Signals for Communication
|
|
539
|
+
|
|
540
|
+
Prefer signals over direct method calls:
|
|
541
|
+
```gdscript
|
|
542
|
+
# ✅ Good - Loose coupling
|
|
543
|
+
signal item_picked_up(item)
|
|
544
|
+
item_picked_up.emit(item)
|
|
545
|
+
|
|
546
|
+
# ❌ Avoid - Tight coupling
|
|
547
|
+
get_parent().get_parent().add_to_inventory(item)
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### 6. Test Incrementally
|
|
551
|
+
|
|
552
|
+
After each change:
|
|
553
|
+
1. Validate with scripts
|
|
554
|
+
2. Test in Godot editor
|
|
555
|
+
3. Verify functionality
|
|
556
|
+
4. Commit to git
|
|
557
|
+
|
|
558
|
+
### 7. Use Export Variables Liberally
|
|
559
|
+
|
|
560
|
+
Make configuration visible and editable:
|
|
561
|
+
```gdscript
|
|
562
|
+
@export_group("Movement")
|
|
563
|
+
@export var speed: float = 5.0
|
|
564
|
+
@export var jump_force: float = 10.0
|
|
565
|
+
|
|
566
|
+
@export_group("Combat")
|
|
567
|
+
@export var damage: int = 10
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
## Using the Godot CLI
|
|
571
|
+
|
|
572
|
+
The `godot` command-line tool is available for running the game and performing various operations without opening the editor.
|
|
573
|
+
|
|
574
|
+
### Running the Game
|
|
575
|
+
|
|
576
|
+
**Run the current project:**
|
|
577
|
+
```bash
|
|
578
|
+
godot --path . --headless
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
**Run a specific scene:**
|
|
582
|
+
```bash
|
|
583
|
+
godot --path . --scene scenes/main_menu.tscn
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**Run with debug flags:**
|
|
587
|
+
```bash
|
|
588
|
+
# Show collision shapes
|
|
589
|
+
godot --path . --debug-collisions
|
|
590
|
+
|
|
591
|
+
# Show navigation debug visuals
|
|
592
|
+
godot --path . --debug-navigation
|
|
593
|
+
|
|
594
|
+
# Show path lines
|
|
595
|
+
godot --path . --debug-paths
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### Checking/Validating Code
|
|
599
|
+
|
|
600
|
+
**Check GDScript syntax without running:**
|
|
601
|
+
```bash
|
|
602
|
+
godot --path . --check-only --script path/to/script.gd
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
**Run headless tests (for automated testing):**
|
|
606
|
+
```bash
|
|
607
|
+
godot --path . --headless --quit --script path/to/test_script.gd
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
### Editor Operations from CLI
|
|
611
|
+
|
|
612
|
+
**Import resources without opening editor:**
|
|
613
|
+
```bash
|
|
614
|
+
godot --path . --import --headless --quit
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Export project:**
|
|
618
|
+
```bash
|
|
619
|
+
# Export release build
|
|
620
|
+
godot --path . --export-release "Preset Name" builds/game.exe
|
|
621
|
+
|
|
622
|
+
# Export debug build
|
|
623
|
+
godot --path . --export-debug "Preset Name" builds/game_debug.exe
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Common CLI Workflows
|
|
627
|
+
|
|
628
|
+
**Workflow: Quick Test Run**
|
|
629
|
+
```bash
|
|
630
|
+
# Run the project and quit after testing
|
|
631
|
+
godot --path . --quit-after 300 # Runs for 300 frames then quits
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
**Workflow: Automated Resource Import**
|
|
635
|
+
```bash
|
|
636
|
+
# Import all resources and exit (useful in CI/CD)
|
|
637
|
+
godot --path . --import --headless --quit
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
**Workflow: Script Validation**
|
|
641
|
+
```bash
|
|
642
|
+
# Validate a GDScript file before committing
|
|
643
|
+
godot --path . --check-only --script src/player/player.gd
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
**Workflow: Headless Server**
|
|
647
|
+
```bash
|
|
648
|
+
# Run as dedicated server (no rendering)
|
|
649
|
+
godot --path . --headless --scene scenes/multiplayer_server.tscn
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### CLI Usage Tips
|
|
653
|
+
|
|
654
|
+
1. **Always specify `--path .`** when running from project directory to ensure Godot finds `project.godot`
|
|
655
|
+
2. **Use `--headless`** for CI/CD and automated testing (no window, no rendering)
|
|
656
|
+
3. **Use `--quit` or `--quit-after N`** to exit automatically after task completion
|
|
657
|
+
4. **Combine `--check-only` with `--script`** to validate GDScript syntax quickly
|
|
658
|
+
5. **Use debug flags** (`--debug-collisions`, `--debug-navigation`) to visualize systems during development
|
|
659
|
+
6. **Check exit codes** - Non-zero indicates errors (useful for CI/CD scripts)
|
|
660
|
+
|
|
661
|
+
### Example: Pre-commit Hook for GDScript Validation
|
|
662
|
+
|
|
663
|
+
```bash
|
|
664
|
+
#!/bin/bash
|
|
665
|
+
# Validate all changed .gd files before committing
|
|
666
|
+
|
|
667
|
+
for file in $(git diff --cached --name-only --diff-filter=ACM | grep '\.gd$'); do
|
|
668
|
+
if ! godot --path . --check-only --script "$file" --headless --quit; then
|
|
669
|
+
echo "GDScript validation failed for $file"
|
|
670
|
+
exit 1
|
|
671
|
+
fi
|
|
672
|
+
done
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
## Quick Reference
|
|
676
|
+
|
|
677
|
+
### File Type Decision Tree
|
|
678
|
+
|
|
679
|
+
**Writing game logic?** → Use .gd file
|
|
680
|
+
|
|
681
|
+
**Storing data (item stats, spell configs)?** → Use .tres file
|
|
682
|
+
|
|
683
|
+
**Creating scene structure?** → Use .tscn file (prefer Godot editor for complex structures)
|
|
684
|
+
|
|
685
|
+
### Syntax Quick Check
|
|
686
|
+
|
|
687
|
+
**In .gd files:** Full GDScript - `var`, `func`, `preload()`, etc. ✅
|
|
688
|
+
|
|
689
|
+
**In .tres/.tscn files:**
|
|
690
|
+
- `preload()` ❌ → Use `ExtResource("id")` ✅
|
|
691
|
+
- `var`, `const`, `func` ❌ → Just property values ✅
|
|
692
|
+
- `[1, 2, 3]` ❌ → `Array[int]([1, 2, 3])` ✅
|
|
693
|
+
|
|
694
|
+
### When to Use Each Validation Script
|
|
695
|
+
|
|
696
|
+
**`validate_tres.py`** - For resource files:
|
|
697
|
+
- Items, spells, abilities
|
|
698
|
+
- Custom resource data
|
|
699
|
+
- After creating .tres files
|
|
700
|
+
|
|
701
|
+
**`validate_tscn.py`** - For scene files:
|
|
702
|
+
- Player, enemies, levels
|
|
703
|
+
- UI scenes
|
|
704
|
+
- After editing .tscn files
|
|
705
|
+
|
|
706
|
+
### When to Read Each Reference
|
|
707
|
+
|
|
708
|
+
**`file-formats.md`** - When:
|
|
709
|
+
- Creating/editing .tres/.tscn files
|
|
710
|
+
- Getting "failed to load" errors
|
|
711
|
+
- Unsure about syntax rules
|
|
712
|
+
|
|
713
|
+
**`architecture-patterns.md`** - When:
|
|
714
|
+
- Implementing new game systems
|
|
715
|
+
- Planning component structure
|
|
716
|
+
- Looking for proven patterns
|
|
717
|
+
|
|
718
|
+
## Summary
|
|
719
|
+
|
|
720
|
+
Work with Godot projects effectively by:
|
|
721
|
+
|
|
722
|
+
1. **Understanding file formats** - .gd is code, .tres/.tscn are data with strict syntax
|
|
723
|
+
2. **Using validation tools** - Catch errors before testing
|
|
724
|
+
3. **Following patterns** - Use proven architectures from references
|
|
725
|
+
4. **Starting from templates** - Adapt rather than create from scratch
|
|
726
|
+
5. **Testing incrementally** - Validate, test, commit frequently
|
|
727
|
+
|
|
728
|
+
The key insight: Godot's text-based files are LLM-friendly when you respect the syntax differences between GDScript and resource serialization formats.
|