Download

How would I have my First person weapon play a put away animation and a take out animation when....

When I disable player control, I want the put away animation to play, when I resume player control, I want the take out animation to play. How would I achieve this?

When you press the desired button just play the animation montage.

It wouldn’t be about pressing a button, it would be more like activating a trigger. i would hate to just have to force the animation each trigger, I would like to have it to where it happens naturally when player control is taken away.

Either way you look at it, you are “triggering” something, so where you take away control, meaning you’re using some event to turn off input or whatever, at that same point call the animation. If this is not the case, maybe give some more info on how you’re going about taking away control from the player. Nothing really can happen “naturally”, you have to make it happen, so it just depend where and when.

So think of it like this.

I want when a player is stripped of weapons/control they play an animation. and same when they are equipped with a weapon/control.

Ok, but what I’m saying is, those two things are “events” right?. So when you call the event to take away weapons, you also call your animation you want to play. To generalize this you can hook up the animation to a custom event, one for Hide and one for Show… or whatever right. Then at any point you can call those custom events. I mean, there are various ways to set this up but that’s the idea.

So lets do an example scenario, lets say you’re walking around and you enter an area where you want to take away control, you’ll have a trigger volume that when you enter, you take away control and after some time you give back control. So you’ll have a blueprint that has a trigger volume inside it, for the script you will have on overlap cast to the player, disable controls on him and call the custom event to drop weapon. Within some time, by using a timer, or a delay, you’ve casted to the player already, added him to a variable, so grab that variable, and now enable controls and again, call the custom event for animation but now to raise the weapon.

So this being a blueprint you can use it anywhere. You can also have it do more stuff, maybe start other events… etc.

Anyway, the point is, you will use events to drive things, to make things happen and when you do, you simply also call your desired animation. Not sure if this is even the answer you’re after, but it’s how I can understand what you’re asking. If not, I guess maybe explain a little more detail?.

You got it right, I was being an Idiot, I totally get what you are saying know. ONE THING What If I have other weapons in my game, how would I make sure it does an animation to a specific weapon dynamically?

If the animation is not part of your player animations but part of your weapon you’ll have a very similar setup. To make it work per weapon will be done directly from your pawn. So you’ll still have the custom events calling the animations but in stead of calling it on the player directly, you will call it on the current weapon.

So the basic idea there is that whether you start with a weapon or you switch to one, these are also events. So starting with a specific weapon will use Begin Play event and switching to another weapon will use whatever event you use to do that. So when this event fires, you will get your current weapon, cast to it, and then set it to a variable. This will be a single variable to use for any weapon, which ever one is currently being used, just over write the variable with current held weapon. The fact that it’s then already casted means you can simply use the variable and have access to that weapon from your pawn. Using the one variable will ensure you keep track of only the weapon you currently hold.

Now you set it up where you play the drop or raise animation on your base weapon blueprint, so it’ll work on all of them. If you don’t have a single base weapon blueprint, you really should have one, it makes life easier with stuff like this. Then on a per weapon basis you will have it reference the correct animation, so when you call that animation custom event on any weapon, it’ll play the correct animation associated with that weapon. Basically you’re making your weapons handle their own animations locally and the pawn can just call on that event. So on your pawn, you have direct reference to your current weapon through that variable, when the animation is called on the pawn, the pawn calls the animation on the weapon.

I will say that this can also be done with Interface, and maybe it’ll be better to do with interface. So communicate with your weapons through an interface. Use an interface event to call the animation in stead of a custom event.

So anyway your external calls are always the same, but the pawn takes care of any special case stuff based on current weapon or whatever else you want to do. Again, this way you have one central thing you call directly on the pawn to activate this behavior, essentially from anywhere, and only the pawn cares what weapon is held… or whatever.

I want to say also that this whole setup can have multiple ways to get the same results. The way I explain it is the way I’d probably approach it and see how it works out and tweak or change based on that if required.

Thank you! I’m gonna check this out, thank you VERY much.