Arena Survivor: Part 2: Shoot Back
Add projectile shooting with scene instancing, preload PackedScenes, spawn bullets with direction vectors, and handle Area2D collision signals.
No login required.
Build the Weapon
Right now your player can only dodge. Let's build an autofire system: a cooldown timer, a frame counter, and a fire condition.
Cooldown timers show up everywhere in games. Once you understand the pattern, you can reuse it for any timed mechanic.
Loading game...
Click the game window to interact with it
What You'll Build
You will add a projectile system so the player can fire bullets toward the mouse cursor. Bullets are separate scenes loaded with preload() and spawned with instantiate(). Each bullet travels in a straight line and is freed when it leaves the screen or hits something. This part introduces Godot's scene instancing pattern — the core workflow for spawning anything at runtime.
Learning Goals
- ✓preload() to cache a PackedScene at compile time
- ✓instantiate() to create scene instances at runtime
- ✓Setting global_position and direction on spawned nodes
- ✓Area2D with body_entered signals for collision callbacks
- ✓queue_free() to remove nodes from the scene tree
GDScript Concepts in This Part
Tips
- ✨Preload bullet scenes as constants at the top of the script so they are cached once, not loaded every frame.
- ✨Use get_global_mouse_position() to aim bullets toward the cursor — it returns the mouse position in world coordinates.
- ✨Bullets should be Area2D nodes, not CharacterBody2D — they do not need physics movement, just collision detection.