Now if you look at the components, you could see how messy it could get after 4/5 more weapons. And the whole arm animation system is broken at the moment and I’m trying to figure out how I’m going to go about doing the weapon switching system, too.
So is there an easier way to handle all of this? could I possibly handle the weapons in another BP yet still have it connected to the players arm? How to other developers handle weapons and arm animations?
Ok so I’m making some assumptions based on the setup I can see in these images so forgive me if I am telling you things you already know.
The first thing you should be looking into is Animation Blueprint, this is where all the animation logic should be handled by any skeletal mesh. I’m assuming your gun is broken down into that many pieces because it has complex moving parts and you need it to animate. If this is the case it would be worth looking into making it a skeletal mesh with animation rather than moving the parts with timelines. If you socket your weapons to the arms then they will inherit any movement from the arm animations and you don’t have to worry about adding that yourself.
When I make a weapon or any other prop that can be carried I always think about how it works before I decide how it is constructed. A knife for instance has no moving parts and therefore it will be brought in as a static object that can be socketed directly to the player and it will inherit the movement just like the real world. A gun still needs to inherit those movements but it has moving parts within it’s frame and so it needs a skeleton to drive those movements, and I would create them as a skeletal mesh.
As far as keeping the logic contained in smaller packages you can create an actor blueprint for each of your guns and then add it to your first person character blueprint as a child actor component. This way all it’s logic is handled indpendently of the user but it’s values can still be accessed through the character blueprint.
You could even create a weapon class that has most of the logic and then create children for each of the weapon types so that you don’t have to create all the logic for things that everyone weapon will have like weapon effects and you can just overwrite the effect that you want.
I know that is a lot of information to ingest so hopefully you get something from it.
P.S. As a general rule it is good practice to not put any logic on tick unless absolutely necessary. If you need something to fire regularly, look into using timers instead. They are more versatile as they can have their intervals set and they can be turned off when not needed.
Saving this answer for later, thank you very much!
I sorted the AnimBP for the Arm_Pistol earlier, it definitely cleaned up the whole Character Blueprint! Only problem I’m having now is that if you shoot fast enough, the shooting animation doesn’t reset, so the arm doesn’t move. I tell you what though, these animations are really smooth now that there’s a blendspace involved!
I’m working on a third person action myself and I found that having an actor class BP_BaseRangedWeapon to store the basic presets and then creating child blueprints for each weapon types helped me a lot!!
I still have a question for Ruffhouse Games: When you switch weapon, to switch the animations, do you use a switch on enum for every arm animations in your graph or do you rather switch arm graph? I also though about having an anim graph for every weapon type (Because I also have melee weapons that change the lower body anims as well) but that seems heavy.
This is a fairly different question, and would probably be worth asking separately to get a wider range of opinions, but the answer really is, it depends.
My opinion on it is if the weapons are varied enough to need a full suite of animations for each weapon type I probably would use a bunch of state machines in the anim blueprint that are controlled by a blend that is run off an enum, so you retain a lot of the shared logic. Alternatively you could also make child animation blueprints and switch which animation blueprint is being used in the character depending on what weapon they have equipped.