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-upBarrelLevels
PhaserProjectile barrel firing DS_PhaserBulletDS_PhaserConfig1 to DS_PhaserConfig4
LaserLaser barrel with a Spool wind-upDS_LaserConfig1 to DS_LaserConfig4
RocketProjectile barrel firing the homing DS_RocketDS_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.
  • DSLevelVisuals grows 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.ApplyConfig with 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 SpawnGroups and DSLevelVisuals.
  • When the player dies, the weapon drops back to level 1.

📁 Scripts

ScriptRole
DSPlayerWeapon slots, power-up upgrades and weapon swapping
DSLevelVisualsGrows the laser’s beam and effects with the level
DSHomingSteers rockets toward a random hitbox in range
DSDropsSpawns a random power-up when a duck dies. Hook it to the duck’s Health On Death
DSPowerUpPower-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.