Check out FelixarStudio’s new retro FPS weapon system that uses Godot Custom Resources and a single Weapon Manager to create different weapons.
The original goal was simple: create a system where developers could build new weapons without touching the code every time. To do this, the project uses Godot Custom Resources together with a single Weapon Manager.
As FelixarStudio said, creating separate scenes like Pistol.tscn or Shotgun.tscn may work early on, but it can eventually become harder to manage as you add more guns.
To avoid that, the system treats weapons as data instead of separate gameplay objects. Each weapon is stored inside a WeaponData resource file with things like:
- Damage
- Fire rate
- Projectile count
- Behavior flags
- Sprites
- Sound effects
Since all the weapon values are stored inside resource files, creating a new weapon mostly happens through Godot’s Inspector. You can create a new resource, adjust a few values, assign sprites and sounds, and from there the system does the rest.
The Weapon Manager itself is attached to the player. Weapons pass their data into the same system, including things like damage values, sounds, fire rates, and projectile settings.
Inside it there is:
- A Sprite2D for weapon frames
- An AudioStreamPlayer for sound effects
- And a RayCast3D for hitscan detection
As FelixarStudio said, this system is currently the foundation for the upcoming Ultimate Retro Shooter Template, a Godot 4 framework made to make retro FPS development easier and faster for beginners.
If you want to follow the projects or learn more about FelixarStudio, the links will be right below.
Interested in learning more? Check out our book!