Duck Shooter
Duck Shooter is a small arcade space shooter included with the package. You fly a ship along the bottom of the screen and shoot waves of rubber ducks, which drop soap bars and power-ups. It shows weapon swapping and upgrade levels built entirely from Barrel Configs.
Open it from the ModularWeaponSystem_Examples hub, or from Glowing Rifts/Modular Weapon System/Examples/DuckShooter/DuckShooter.unity.
Note
The example scripts live in the GlowingRifts.ModularWeaponSystem.Example namespace, so they don’t clash with your own code. The ducks, waves and player health come from the Modular Health System’s own Duck Shooter example, which this one builds on.
🔫 Weapons
The ship has three weapon types, each a barrel with four levels:
| Power-up | Barrel | Levels |
|---|---|---|
| Phaser | Projectile barrel firing DS_PhaserBullet | DS_PhaserConfig1 to DS_PhaserConfig4 |
| Laser | Laser barrel with a Spool wind-up | DS_LaserConfig1 to DS_LaserConfig4 |
| Rocket | Projectile barrel firing the homing DS_Rocket | DS_RocketConfig1 to DS_RocketConfig4 |
Each level is a BarrelConfig asset that changes the fire rate, damage and bullets fired. Example scripts add the visual side of each level:
- Spawn Groups gives the barrel more muzzles per level by calling
barrel.SetSpawnPoints. DSLevelVisualsgrows the laser’s beam and effects per level.
Tip
The rocket steers with DSHoming, which picks a random hitbox in range and flies straight once its target is gone.
⚙️ How It Works
DSPlayer sits on the player ship and holds one Weapon Slot per power-up type. Each slot has a barrel, its list of level configs and an optional magazine (empty means infinite ammo).
When the ship picks up a power-up:
- A power-up of the current type upgrades the weapon to the next level, by calling
barrel.ApplyConfigwith that level’s config. - A power-up of another type swaps that type’s barrel and magazine onto the weapon at level 1.
- On Level Changed reports the new level, which drives
SpawnGroupsandDSLevelVisuals. - When the player dies, the weapon drops back to level 1.
📁 Scripts
| Script | Role |
|---|---|
DSPlayer | Weapon slots, power-up upgrades and weapon swapping |
DSLevelVisuals | Grows the laser’s beam and effects with the level |
DSHoming | Steers rockets toward a random hitbox in range |
DSDrops | Spawns a random power-up when a duck dies. Hook it to the duck’s Health On Death |
DSPowerUp | Power-up that falls toward the player and is collected on touch |
Tip
For a single weapon that only levels up, use an Upgradable Weapon instead of writing a script like DSPlayer.