Skip to content

Gun Controller

Quick ranged-weapon setup for the Combat System. Handles firing, reloading, ammo accounting, network replay of shots, and animator parameter wiring.

string. Used by the combat-system networking to identify this gun. Populated by the inspector.

The Unity Particle System used by the weapon.

List of audio clips randomized while shooting.

List of audio clips randomized while reloading.

List of audio clips randomized when firing with no ammo.

Ammo available before a reload is required.

Total ammo available to reload into a magazine.

  • Single The weapon must stop firing before it can fire again.
  • Half Auto Fires the number of rounds equal to the Firing Rate, then must stop firing before it can fire again.
  • Full Auto Fires a continuous stream of rounds per second (Firing Rate) until firing stops or the magazine is empty.

Rounds per second.

Time in seconds a reload takes.

  • Particle Uses the Particle System collision property.
  • RayCast Uses an instant raycast.

Unity Collision Matrix layers the Gun Controller can hit.

Methods that can be called from Custom Triggers in the CVR Interactable component.

Adds ammo to the magazine, up to the Magazine Size.

Adds ammo to the reserve, up to the Ammo Capacity.

Reloads the magazine.

Fires once per call.

Fires until ShootUp is called or the magazine is empty.

The Gun Controller writes to animator parameters on the same GameObject. Parameter names are case sensitive.

Integer. Max magazine size.

Integer. Current magazine ammo.

Integer. Max reserve ammo.

Integer. Current reserve ammo.

Bool. Whether the weapon is reloading.

Bool. Whether the weapon is firing.

Bool. Whether the weapon is firing while clipAmmo is 0.

CVR-GameFiles/ABI.CCK.Components/GunController.cs