Overview
On this page
Each weapon is split into different behaviors which each control an aspect of the shooting experience:
- Trigger - How the players shooting input is applied
- Clip - How the gun consumes and reloads ammo
- Target - Where to aim the projectile/emitter
- Recoil - How the guns state changes after a shot is fired
These behaviors can be templated and inherited from so that the core functionality can be shared between weapons and variables can be overridden inline in the weapon data. Each behavior can define its own Attributes or may choose to share common attributes with other behaviors. Effort has been made to provide all functionality to extend behaviors in both code and blueprint.
To create a new weapon behavior or inherit from an existing behavior, right click in your Content Browser and select the desired option under Gunsmith->Behaviors.
Note
All behaviors run within the rollback simulation so if a desync is detected, state will be restored and logic will be executed a second time until caught up again. Therefore it is recommended that all logic is kept simple and deterministic. To execute more complex logic such as creating VFX you may use cues or that system should read directly from the shooting component state (e.g animation blueprints).
Emitters
An Emitter is a behavior that can be given to a weapon to produce an object which applies damage to a target. The most obvious example here is a projectile but this could also be a beam or a trigger volume to apply damage within an area for a melee hit. Each weapon may have more than one emitter if necessary.
Extending a behavior
Behaviors can be extended like any other class in Unreal via C++ or Blueprint. To keep data organised in a way that NPP can use, there are a few quirks around how to update that data.
Each function in a behavior should give access to UGSShootingTickStartData and UGSShootingTickEndData. The start data is the simulation state before the current simulation frame has started and the end data is the data to be sent back to the simulation which will then be the start data for the next frame.