Better way to switch weapon : switch BP or meshes?

Hello,
I am doing a multiplayer game and I was wondering what is better between creating a blueprint for each different weapon or creating only one weapon blueprint and change mesh each time we change weapon.

First, I thought to create only one blueprint and switch the skeletal mesh that it uses for switching weapon.
But I saw a tutorial where the person create a blueprint for each different weapon (each different mesh).

In my case, I have Skeletal mesh that are not all from the same pack, the rotation is not the same for all. So, weapon doesn’t place well when I attached them to the socket if I switch weapon just by changing skeletal mesh.

I think that if I create a blueprint for each different skeletal mesh I will be able to change parameters in it and then just spawn the blueprint and everything will be right placed (good location, rotation…).

So, in my case what is better ? I might have over 100 different meshes so it will conduct in creating 100 blueprint, it seems really… awfull ? But in another hand it will let me change the exact location of the objet in the hand easily…

The first solution was logical for me because in programming, it doesn’t have any sense to create an object for each things like that. It is more logical to create an object weapon with a variable mesh…

Could someone advise me for my problem ?

I am sorry for my mistakes, I don’t speak english very well…

Thank you for your answers !

All the best

1 Like

Create a Struct and a Data Table for weapons and then simply use a Master blueprint for weapons you pick up. In the details panel you can type the ID of the weapon and it will dynamically change the mesh when you hit enter.

Then, you can use a BP with an interact interface so that when you interact with the master it passes the item stats on to the player and equips it, changing the mesh as well.

Hope this helps!

Agreed, struct + data table or depending on if things will actually be “different” like firing a projectile vs a hitscan weapon vs some visual beam weapon etc you may need to create a parent class and child blueprints to handle the various effects of your weapons. If everything is basically the same “style” of weapon (all shoot bullets, or all projectiles) you may not need this and a data table will suffice with the different stats. If you need a basic example of how parenting can work to your advantage here check out video #15/16 below.

Thank you for your answers :slight_smile:

I am already using a datatable with an ID of the weapon and the mesh of the weapon. So you advise me to switch mesh and not switch blueprint, am I right ?

Sure if I have a sword and a bow I should create another blueprint instead of switching weapon.

Is it that ? That you for you answers again !

I made weapon system with base weapon that only has startInteract and stopInteract methods. Every thing else is child
Example of scattershot crossbow:
BP_WeaponBase->BP_MeleeBase->BP_FirearmBase->BP_CrossbowBase->BP_Crossbow_Scattershot

That way i can make anything modular. And my Crossbow is also Melee weapon :smiley: (I’m on VR game)

If possible, I would suggest setting a common standard for all weapons within each category. Like similar pivot positions, rotations, etc for all swords. That would save you a lot of headache in the future, especially if the game is going to have lots of weapons.

But if that’s not an option at all, then try out each of the meshes in your character’s skeletal mesh preview and note down the required rotation for each of them. You can then add this data to the data table for each weapon and use it to set the correct rotation while spawning the weapon.

As for switching between meshes vs blueprints, Faithdrawn and NebulaGamesInc have already provided the solution. If all your weapons function similarly, then you just need to change the meshes.

But if they fall into different categories like a hitscan rifle, projectile based rocket launcher, melee sword, etc then it is better you create child blueprints for each of them. So that way you won’t have 100 blueprints for 100 weapons. You have one for each weapon type and while spawning the weapon, you set its mesh using the data table info.

Thank you very much everybody !

I manage to do it as you explain me and it is working very well.
Just a last question for Stromrage256, you said me that I can setting a common standard for all weapon. But what do you mean by that ? In fact, as I said my weapon haven’t all the same rotation. Is it a way, in Unreal, to edit this weapon (edit the skeletal mesh) to make them have the same rotation ? Is it what you mean ?
If there is a way to do that would you explain me please because I am really interested by this solution.
Else if it is not possible I will store the rotation in the datatable as you said :slight_smile:

Thank you again everybody !

I meant to say that if you end making your own weapon meshes (which is usually important if you want to maintain same artistic style across all weapons) or have a teammate take care of it, you might be able to create the meshes such that they retain similar rotational attributes upon importing to the engine.

Not really sure if it can be done within the engine. I’m not very acquainted with the animation side. So someone else might be able to give you a better answer on that.

Hi there, maybe someone in this thread has an idea for my problem too:

The posted answers help for projectile weapons but how would you do this with melee weapons?

Then having a base class and a child class for each concrete weapon has the advantage that you can have a collider and the collision and damage handling in the base, and then override the mesh and the collider in the child class (cause the collider might be different for an axe or a sword.

DataTables don’t seem practicable for handling dynamic collider sizes. (or do they?)

With destroying and spawning the actors, I have the advantage of very easy and dynamic weapon definition through child classes, but it seems that there is some flickering when the switch happens (caused by spawning the actor at 0,0,0, then attaching it to MainHand socket).

Any ideas?

Cheers and thanks in advance :smiley:

Stormrage256’s answer goes that way, but how would I avoid the flickering when switching weapons?

You should post a new question, this question is from 5 months ago and your question (though similar) isnt supporting the question to be answered, also its difficult to find your question in this post.

That being said, I recommend spawning all weapon types initially and attaching them all to the socket but only having one active/visible. When switching weapons simply hide and show the new/old one. This is easier to process and can be far more beneficial in a MP game as well.

Not adding to the answer but maybe adding information for other ppl who might read this.

How does initially spawning them all make it easier to process and for MP? Doesn’t it add a lot of overhead?

Also I thought it quite convenient that my BP doesn’t have to know about all the different types of weapons (which might be quite a few).

Thanks for your help though!