The best and easiest way to make a gun system like in COD & Battlefield games

Hello guys. I am going on a first-person shooting game project like COD, Battlefield using Ue4. So I want to know the best(easy) way of making an advanced gun system.
My gun system is to be like in COD and battlefield games. There are two guns.

I know one method. In this method, there is a major blueprint for pickup guns(fallen guns on the ground, tables). Then create child blueprints to that major pick-up guns.
There is another major Blueprint for playable guns which can be fired by the player character. then create child blueprints for that major playable gun blueprint actor.
each ‘pickup gun blueprints’ and ‘playable gun blueprints’ are connected through a variable.


The ‘firing, reload’ functions are in the playable gun blueprints.
I think you too know about this way. But I have a problem with this method. That is the functions may different according to the gun’s features. So, should I
use variables and check branches(if conditions) to change the functions according to the gun features in each gun?

I watched a video about an asset called “MP SYSTEM 2”. In that asset, there is a data table, and details are attached according to the gun’s features.
**but I don’t know how that mp system works because I didn’t download it. **

So can u please tell me the best way to make this weapon system and if that best way is the MP system, can u tell me how that works?

THANK YOU SO MUCH​:heart::heart::heart::heart:

Hmm I could not make much out of your description (I did read it twice), maybe because it is before my morning 0xCAFE today.

However i did few iterations on flexible gun andd firing systems. And here are my ideas:

  • use inheritance, create base weapon that is just code with placeholder gun, then every real gun inherits from it.

  • either use “mid” level child gun or blueprintable objects, for middle level of code. This depends on how pressing and releasing fire button is processed by code:
    I split weapon classes into:

    • single fire (like sniper rifle),
    • automatic fire, like any automatic gun
    • continuous , for eg. flamethrower.
      Those 3 types can be handled as separate inherited classes , or blueprintable component that connects to code of gun. Second way is less code and maintenace imo, when you change code for gun you have single blueprint class, not 3 to update.
  • FSM - finite state module or anything with finite state machines, makes coding above behavior easier, but then some of those modules cost, are c++ not always multiplatform etc.

  • then you need flexible system for animation, reloading etc.

  • also system for particle effects and sound. I found out that best is to use animated weapons and add effects/sounds as events in animation. So animation calls them, your blueprint code executes.

  • and you need projectiles. I implemented them as separate blueprint class. Weapon only spawns that class (with muzzle flash transform (location and rotation of barrel end point). Projectile blueprint either spawns projectile or line trace

  • last is blueprint class that handles effects of hit. that is temporary blueprint that spawns on hit target, modifies its hp/damage, spawns particle effects like fire, damage decals etc.

So when you have all above, and independent systems done. All you need to do is spawn gun blueprint in hand of player, rest will be done automatically.

Last thing to do is make diffferent gun models and create inherited “top level” guns all with specific models, textures, info about shooting mode, ammo, max ammo and all that.

Then hot to spawn them player loadout and all will be quite simple task.

I went with low data SM based weapons for world/dropped. And SK weapons for high data skeletal mesh (usable).

SM_Weapon (parent)

  • SM_AK47 (child)
  • SM_UMP (child)

SK_Weapon (Parent)

  • SK_AK47 (child)
  • SK_UMP (child)

They each have a class reference for the matching variant.
e.g. SM_AK47 will have a SK_AK47 class reference and vice versa.

When you pick up the SM … line trace/overlap/BP interface get the class reference. Destroy the world item, spawn the SK variant. Flip the process for dropping.

Hey @Nawrot , Currently I’m marking a similar weapon system and I’m having trouble adding particle effects and sounds to the guns, for adding them into the gun animations would I create a separate anim blueprint for each gun or use montages?

It depends if you have animations for guns or you better coder than animator.
If you use assets from marketplace make sure they all use same socket names, socket orientation etc. Or edit them to follow same rules, less code this way.

If you have animator it is much less complicated to use anims and montages. I kind of lost my old backups (they all are 4.xx and corrupted from me being i@#$@ and trying to upgrade them to 5.1 without backups of backups). And i do not remember how i made those weapons those years ago.

I think i just played animation from blueprints, so it probably was anim montage with events firing from it to play sounds eject shell.

Muzzle particles were in same actor that spawned projectile, so this was separate from gun anims and blueprints.

This may contradict my older posts, however i write it again how i remember this gun setup:

  • parent blueprint had logic for different projectile types and different shooting cycles like hitscan, rocket, grenade, projectile component. Then single shoot, semi auto (reload after full magazine but single shots when you press trigger), full auto etc.
  • then there was gun blueprint with animations spawning of sounds etc.
  • and actor that was ammunition type that spawned projectile at muzzle location

In blueprints split code into separate smaller actors or components, it is easier to maintain it this way, keep some logic to what goes where so you can remember/rediscover it after year or two.

So for your question i added BP_projectile actor to muzzle socket, it had event that was triggered from weapon parent to tell when to fire stuff. And that weapon event was triggered by animation event placed in montage.

Right now I’m using the Military Weapons Silver free asset pack from the marketplace, and it does come with animations for the guns so I could use montages. Thanks for the help on the weapon system! Once i get it working I’ll put the BP here for anyone wanting to see it