Easier way to switch through animations?
Well, I'm doing a weapons system and each weapon will have 4 animations: Idle, walk, run, and shoot.
Except, these aren't weapon animations at all; they're all in the character's arm. The problem is, the BP is gonna get pretty huge.
I mean here's just part of the 'event tick':
And here is the shooting script for just the pistol:
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?
asked Aug 10 '17 at 04:51 PM in Blueprint Scripting
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.
answered Aug 10 '17 at 11:20 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here