
All the behaviour that your weapon needs to exhibit should be taken care of by the specific weapon type master blueprints which you will have derived your item class from.
Nevertheless, sometimes, you need special handling of some aspect of your weapon beyond what can be done by setting appropriate class defaults as set out here.
If you open the blueprint editor and go to the Functions section on the left hand side, and click Override
, you will be presented with a list of events and functions that you can override in your blueprint. The precise list may depend on the master blueprint class you are derived from, but an example list follows here:
You can see that some events/functions are from GBFirearm (the base c++ firearm class in GROUND BRANCH), some are from BP_Firearm_Master (the implementing master firearm blueprint), some are from the specific BP_AR15_Master parent blueprint (LockOnEmpty
), some are GBItem (relating to general inventory handling), and some are universal overridable functions (actor).
To override an event or function, just click an item in this list, and an appropriate event or function will be created.
There follow some examples of overrides in specific weapon blueprints that can be found in stock GROUND BRANCH weapons. The first three examples are relatively common, and the last two are one-offs.
Event Update Safety Alpha
is called (amongst other times) when the the fire selector mode is changed. This gives the specific weapon blueprint a chance to set the safety button alpha to a desired value based on the type of safety/fire selector button that the weapon has. For example, the code above will select a fire selector button position in dependence on whether the weapon is in semi auto fire mode (that is, a burst count of 1).
On Sight Zeroing (<Component>)
allows the specific weapon blueprint to set an appropriate Rear Sight rotation based on the input zeroing.
On Set Front Sight Post Height Offset <SightComponent>
is called when a sight is zeroed (automatically, when the weapon is initialised or when a new sight is placed).
See sight component properties for more details.
This code example is from the M24 sniper rifle, where multiple rounds are loaded into the rifle at one time. This means that the display of rounds must be handled by the weapon as well as by the magazine. The BP_M24_Master blueprint calls a specific EventUpdateBulletVis
event to allow derived weapons to show or hide bullets in dependence on the Bullet1Vis, Bullet2Vis, … Bullet4Vis bool properties.
In this example from the MP5A4, the foregrip element is hidden when a handguard is added. You can use code like this if, for example, you need to hide a standard/stock part of a weapon that would be removed (or would otherwise clip with things) if a particular attachment is added.