So last few weeks I have been trying to create a weapon system. I just wanted to ask are there more ways how to do it besides adding child actors to the character bp and setting up enum for the weapons(also doing this way character BP holds all the weapons info). I am afraid to use this method because I will have a lot of weapons which can be picked up like in H1Z1/DayZ and I really didnt like when you have to hide every weapon if it’s not being used. TL:DR how to cast several weapon classes + mesh to the character? Because currently I have fire/sounds/animations inside the weapon BP and if I move everything to the character BP it will just be messy.
Yes, you can easily use SkeletalMeshComponent in the hands of your Character. When you switch Weapons, simply exchange the mesh of the weapon. You should separate the physical representation of the weapon and the logic of it.
The best way is to use either an interface or an abstract class for the functionality for weapons. This way every weapon can be used the same way, but may have different behaviour.
In my Project, weapons are UObjects, not AActors.
I have a separate Actor for Pickups and the UObject Weapon implements an interface, that returns the Mesh.
I have tried creating an object before and assigning a class to it but it didn,t work. I am using interface for weapon equip animation so I will try using the interface for different weapons first. Btw, do you have some demo to share by any chance? if not, maybe you have seen a tutorial on how to do it?
Here’s one I always liked but that’s for real-ish switching of weapons:
Alternatively you could check this out:
Thanks for your input.
I already have the 1st system implemented. I’ve seen the second one but I wasnt sure if I will be able to use it as I want to. But if you think that the second one is a good example on how to handle a lot of weapons I will try to do something.
I store the Animations of the character in the weapon itself and use a State Maschine with these Animations concurrently to the base Animations.
Every Weapon has an Animation for Drawing, Aiming, Shooting, Idle and Holstering.