Best method for modular gun system?

So I’ll try to keep it simple.

I need to be able to build a gun from various parts. There will be different receivers, Magazines, stocks and barrels.

-Receiver

—Mag

—Stock

—Barrel

And i want them all to have influence on the final gun when shot. Firing modes, fire rate, recoil, mag size etc.

So I’ve been meddling around in different ways to try to make 1 gun that can be built in front of you by selecting a receiver, then selecting from a list of “basically child parts” that can attach to the receiver. My problem is i get it to sort of work, jankily, and then I’m having problems passing over variables from child actors components to the receiver. I know there’s a better way to do this but I’m not entirely sure how i should be setting it up from the start.

Any Thoughts guys?

As long you have valid references, there shouldn’t be any problems in the passing of variables between components or actors.

  • What kind of problems are you talking about?
  • How are you building the weapon?

I’m basically talking about being able to select a receiver, which i haven’t decided whether or not each different receiver should be its own Child BP; or just a swap-able skeletal mesh in 1 actor BP. Then setting child actor components, based on the ‘part’ button you selected in the UI, that are designated children of the receiver skeletal mesh, and set to attach on a parent socket(which are all set up on the receiver skeletal meshes).

I’m really just confused on the best way to pass the variables and whether or not i should be using JUST ONE weapon blueprint for all of this and swapping out all of the parts and to make a new gun each time.
Like, if i did that, how could i save that gun to a loadout slot or something, and start building a new gun to be able to bring both into a game at once and swap them while fighting

Like you, I would consider the weapon as an actor with the receiver as the root and the mag,barrel and stock as skeletal mesh components.
Depending on the degree of functional modularity you wanted, these would actually be components derived from a skeletal mesh component. That way I would be able to include functionality and data inside the individual components, for example, the magazine component would hold its capacity, ammo count and so on.

304536-0.jpg

Then, I would start by experimenting if data tables would work in my case. This would really help in building a weapon selection/build system.

Now, let’s take just the magazine for example.

  • We would have an enumerator with an indication of the type of magazine

  • We would have a structure with all the data related with the magazine: capacity, type, caliber, mesh reference, …

The entire weapon would be then defined by just 4 row names, for each respective table (mag table, barrel table, stock table, barrel table).
It’s build would be quite straighforward:

In the weapon BP::

To spawn the weapon, we would only need to specify the table row for each part:

if you want use this series if you want make changes to the level this is a fps series if you dont like thier level design make your own still this series is very help

if you want use this series if you want make changes to the level this is a fps series if you dont like thier level design make your own still this series is very help