godot-game-loop-collection
Original:🇺🇸 English
Translated
Use when implementing collection quests, scavenger hunts, or "find all X" objectives.
7installs
Added on
NPX Install
npx skill4agent add thedivergentai/gd-agentic-skills godot-game-loop-collectionTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Collection Game Loops
Overview
This skill provides a standardized framework for "Collection Loops" – gameplay objectives where the player must find and gather a specific set of items (e.g., hidden eggs, data logs, coins).
Core Components
1. Collection Manager (collection_manager.gd
)
collection_manager.gdThe central brain of the hunt.
- Role: Tracks progress ().
current / target - Behavior: Listens for -> Updates items -> Signals
item_collected(id)on valid count.collection_completed - Tip: Use strings to run multiple hunts simultaneously (e.g., "red_eggs" vs "blue_eggs").
collection_id
2. Collectible Item (collectible_item.gd
)
collectible_item.gdThe physical object in the world.
- Role: Handles interaction and self-destruction.
- Behavior: On Interact -> Play VFX -> Emit Signal -> Queue Free.
3. Hidden Item Spawner (hidden_item_spawner.gd
)
hidden_item_spawner.gdAutomates the placement of items.
- Role: Populates the level.
- Behavior: Instantiates the item scene at:
- Hand-placed nodes (Deterministic).
Marker3D - Random points within a volume (Procedural).
CollisionShape
- Hand-placed
Usage Example
gdscript
# In a Level Script or Game Mode
@onready var manager = $CollectionManager
func _ready():
manager.start_collection("easter_egg_2024", 10)
manager.collection_completed.connect(_on_all_eggs_found)
func _on_all_eggs_found():
print("You found all the eggs! Here is a bunny hat.")
# Unlock rewardBest Practices
- Persistence: Combine with to save which specific IDs have been found if the player needs to quit and resume.
godot-mechanic-secrets - NEVER hardcode spawn positions in code: Always use or
Marker3Dnodes in the scene so designers can adjust layout without touching code.CollisionShape3D - Avoid "God Objects": The shouldn't handle input, UI, AND audio. Let it emit signals and let other systems react.
CollectionManager - Juice: Always spawn particles or play a sound before the item disappears. Immediate feels dry.
queue_free()