When weapon fires
Fires each time the weapon discharges a shot.
Introduction
When Weapon Fires is an event in the Ranged Weapon group of World Events. It fires each time the weapon discharges a shot. Like every event, it does nothing by itself. It waits for the right moment, then runs all the actions connected to it. Use it for shot feedback that plays on every pull of the trigger: muzzle flash, recoil animation, ammo tick. When it fires, the event hands one value to your script: player, the player this moment belongs to. This event belongs to the Ranged Weapon component. Open the Ranged Weapon component guide to see everything the component itself can do. Firing is the start of the ranged chain: this event fires on every shot, When Bullet Hits reports each target struck, and When Critical Hit Happens celebrates the lucky ones. Damage flows into the health family via When Health Decreases , and the weapon itself - fire rate, spread, ammo - is configured in the Ranged Weapon guide. When weapon fires event in the Uni editor Image The When weapon fires event in the Script Editor.
Parameters
Player the player holding the weapon Parameter Description
How to Access
How to Access - Event When weapon fires
How to Use
Select the ranged weapon in the right panel , then click its Propertie (the blue equalizer icon) and scroll to the bottom of the properties panel — the When Weapon Fires event is already listed there. Press the + button below the event to add a script, then press Edit on that script to open the script editor and build the actions that should run when the event fires. Press Play and fire the ranged weapon, then check that the actions run.
Example
When weapon fires: Set Player Player Var.Shot Count Add 1 when-weapon-fires-example.png Adds 1 to the player's shot count variable with every shot fired. caption
Common Uses
Muzzle flash and gunshot sounds Count ammo or shots fired Recoil and camera kick effects
Tip
This fires on every shot of a burst too. Add a small delay between effects if the burst should not sound like one long noise.