Bullet Magazines

The BulletMagazine is a clip-based magazine with support for manual and automatic reload. It extends the abstract Magazine base and is commonly used for ballistic weapons like rifles and pistols.

Summary

This component:

  • Uses a clip-based ammo system
  • Supports timed reload with events
  • Optionally resumes shooting if interrupted
  • Handles player reload input

Fields

FieldTypeDescription
_autoReloadboolIf true, the magazine reloads automatically when empty.
reloadTimefloatDuration of the reload in seconds.
reloadableboolIf false, disables manual reloading.
_controlsWeaponControlsInput bindings for reload input. (Runtime only)
_waitRoutineCoroutineCoroutine handler for timed reloads. (Runtime only)

Inherited Fields

See Magazine for:

  • clip, clipSize
  • OnDepleted, OnStartReload, OnReloadComplete

Public Methods

MethodDescription
override void Reload()Starts the reload process, invoking events and managing timing.
override bool IsDepleted()Checks if the clip is empty and optionally auto-reloads.

Private Methods

MethodDescription
CompleteReload(bool wasShooting)Resets clip, optionally resumes shooting, and fires events.

Input Behavior

  • Listens to the Reload input from the WeaponControls input map.
  • Only active if reloadable == true.

Reload Flow

  1. Player presses reload key (or auto-reload is triggered).
  2. Events:
    • OnStartReload is called immediately.
    • After reloadTime, clip is refilled.
    • OnReloadComplete is called.
  3. If the weapon was shooting when reload started, it resumes firing automatically.

Tip

You can bind SFX, VFX, or animations to OnStartReload and OnReloadComplete.

Warning

Don’t forget to disable reloading logic for energy-based weapons that use charging instead.

See Also