What is The Best Way to Animate a Weapon?

Hey community :slight_smile:

I’m trying to add animations for a weapon that I made and animated in Blender. I have three animations imported: two of them are animations for the bolt cycle and trigger pull, and one is a three frame animation with each frame correlating to a different position of the fire mode selection lever. I would like to use notifies on the animations to trigger some events too. The weapon itself is an actor class and I have the functionality pretty much done already, I only need to add the animation.

Here is the setup:

So the issue is how the hell do I do this? I tried using a montage with notifies, but it wouldn’t work at all. I also used an animation blueprint but I’m not sure if it’s good practice to create an animation blueprint for every weapon you have + using the notifies to trigger e.g. the brass ejection is more complicated this way. I would appreciate some direction on what would be the best way to do this :slight_smile:


The best way is to not animate anything.

You can move the bones, like the bolt dynamically or by the animation of the player character.

This ofc doesn’t necessarily produce the best possible animations / particularly if you need to do complex things like hitting the bolt to clear the weapon from a jam.

The next best thing is to sync animations.
You can leverage sync groups for this. Or you can play more than one montage. Depends on what your weapon setup is.
Having a weapon with an animation blueprint is essentially the best way for this.

Assumption 1:
Holding a weapon is a montage on character.

Assumption 2:
ADS (aim down sights) is a different montage on character.

Assumption 3:
An aim offset modifies the montage properly.

Assumption 4:
Firing the weapon is also a montage.

Assumption 5:
Weapons are their own master BP with functions.

Cast and save the animation blueprint instance for access.

Toggle the animation blueprint “firing” boolean which causes the animation to play.

On player:
When player picks up the weapon initialize it.
Something to set the weapon variables at the time the player picks it up or equips it is kind of ideal if maybe a bit overkill.

When the player presses the fire button you play the fire montage on the player, and call the fire event for the weapon.

Now to avoid casting to the weapon from the player you can convert to using a blueprint interface.

The baseline theory is always the same:
The main blueprint takes care of toggling variables in the animation blueprint.

How you get to that can vary wildly.

Isn’t moving the parts individually basically the same as making an animation for it? :thinking: I want to use the animations I have already but I’m just wondering how I should play them?

You mentioned using a montage. I tried it inside the weapon blueprint and I couldn’t get it to work properly, especially with the notifies. So should the montages be used inside the animation blueprint or can you use it elsewhere?

On a mechanical object, if you do things correctly. Yes.
Particularly if you pull the bolt back for a check.
There’s only one axis for the item to move, so it isn’t complex by any means.

Doesn’t mean animations for it are a bad idea either.

Animation blueprints should never have any code.
Look up the Fast Path documents.

I’m not sure what you mean by not using any code inside animation blueprints? :thinking: Do you mean just inside the “anim graph” or what? Isn’t the whole point of the animation blueprint’s event graph to write code for the animation?

And also I tried searching online but couldn’t find any good documentation on using montages.

It’s purpose is to purposely make people think that’s what it is for only to find their project runs like trash a year later when they start to optimize.
It’s an Epic™ thing, like most BS of the engine.

A simple Google search for “ue4 animation fast path documentstion” should get you what you need to set things up correctly.

As far as the montage goes.
There could be a billion reasons it isn’t playing.

Start with the official documentation on setting up montages. Move on from there.

Also the Learn tab has some relevant courses on this.

Okay, but back on topic:

Should I combine the animations into one and use the montage to play parts of it, or can I play the individual animations too if I convert them to montages? :thinking: And is it possible to play a single frame of animation with montages?

(On the official documentation I found that you need to have a default pose set inside the animation blueprint which I didn’t do before so maybe that’s why it didn’t work)

Though not as annoying as one. Your animation blueprint (which then disappeared) is nothing but the equivalent of a parrot.
Completely unnecessarily repeating things that already exist.

As stated before.
All changes need to happen on the holding blueprint when relevant.

There are several discussions detailing “how”. Search the animation forum for fast path. See whatever people do/suggest. There’s a LOT.

Yes, but to make montage sections you need to make a montage up of different animations. Ergo, you’d have to cut the single frame out as a single animation.
If you look up the good-ol Jump Animation state machine tutorial I do believe it presents how to cut in engine. After-all the looping part of a jump is often a single frame.

In a DCC? maybe. Then in engine you can split if needed.
I prefer to keep my animations as directly saved out FBX files. Less space on disk. easy to change / use. This is just dependent on whatever your personal preference is.

You can play anything as a montage if you create a montage with it inside.

Again. The montages aren’t necessary for a weapon if you do things right with a master blueprint and a standardized animation blueprint.

The end result however is probably the same unless you are targeting something like an N64 which even if you wanted to you couldn’t do with unreal.

As stated before.
All changes need to happen on the holding blueprint when relevant.

Ohh, do you mean that I should e.g., have variables in the animation blueprint that I use in the “anim graph” strictly to switch between animations, but set the variables inside the actor that uses the animation blueprint? :thinking:

Also, can I just have multiple montages playing at the same time if e.g. I want to have the weapon bolt moving and the trigger pulled?

In essence, yes.

Yes, but on different slots.
part of why doing montages for weapons isn’t necessarily ideal.

1 Like

Alright, so I did it like this in the anim graph now and the animations work:

I don’t have anything in the “event graph” of this animation blueprint. I only use the montage (in the actor blueprint) for the bolt cycle as I want to use notify triggers from it to trigger stuff. Is this fine regarding the “no code” thing you mentioned? Also please let me know if you know some better way to do the same thing.

Whar you shared seems ok.
Additive and the montage are ofc separate things.

The montage will play on top of whatever additive animation is happening.

Re notifiy.

Notifies aren’t normally good enough to sync.
There’s no guarantee a (normal) notify will fire right away - by design.

So you either change the type of notify to the ones that cost you more execution and always fire (check doccs) or you avoid using them.

To avoid using them, you can do things based on time.

With the assumptions from before…
You can take the output node of a montage which returns the time, and check that it’s a value you know before triggering the animation blueprint montage - or whatever else/however else.
Even doing it just that simple in BP is more exact of a result than the regular notify.

1 Like