Download

Best general way to implement gun animations along with existing walking animations

I am using Advanced Locomotion in my project.

It has existing complex animations for walking, side stepping, jumping, coming to a halt, etc…

For each gun the player can equip there will be multiple animations specific to that gun. Such as reloading, shooting, equipping. Must I then create animations for each of those states for that specific gun? Such as: ak47 reloadWalking, ak47 reloadRunning, ak47 reloadJumping, pistol shootJumping, etc…

As you can tell, that would be extremely cumbersome and unmanageable. How do games like Fortnite handle this?

Look into bone IK

However the old school way is to pump out separate animations.

That is a crazy amount of animations. Definitely not doable by myself. I will look into bone IK. Is this what games like Fortnite and Rust use?

I am not familiar with the Advanced Locomotion but conventionally you would use montages and layer blend them by bone to play animations. I would suggest looking up several tutorial series about them https://www.youtube.com/watch?v=MhMJt3VWfk0

So, ideally you would use “Layered Blend by Bone” in your Animation Blueprint such that everything below “spine” bone (for example) will come from your movement state machine (walking, crouching, prone etc) and everything above will come from a montage (shooting, reloading, equip/unequip).
Hope that’s helpful!

That’s very helpful. Upon more research, it seems I must create an aim offset for each animation? One for each gun as well as iron sights and hip position. However, if the player reloads, won’t this break the aim offset and require me to create a specific aim offset for reloading?

That’s the “I dont care” way to make anything. Since I care I definitely wrote too much…

No. your gun states need their own idle/walk/run. That’s not really an opinion it’s a must, even to adjust the bone ik.

download the free anim starter pack, it comes with some examples of gun movement.

Also get the jetpack one that’s currently free and look at how they did things in there.

Lastly, let’s not go skipping things because “oh I can just blend”.
You move differently when you carry something. You move even more differently when doing different activities.

Everyone of those movement states should be accounted for, with either in it’s own state machine or a blend space utilizing a somewhat complete animation.

Let’s also address a couple things. Are you making this in 3rd person or first person?

first person you could get away with a blend if you polish the enemies to have a couple different states. You’ll be generally too busy killing them to notice they move badly.

if you are instead doing this in 3rd person or with a camera switch, well then you need a beefy animation blueprint with numerous states to have the game feel “normal”

The anim starter pack gives you a run down of a walking with rifle state and you can and should quickly include the different parts which need additional animation.

you’ll get idle, walking, and running animations while holding a rifle, as well as a few directional version that really are quite different.
you’ll also get a couple of reload/equip which you can blend to locomotion if appropriate (I wouldn’t do so while crouching for instance).
the prone state only has very few animations and needs to be manually expanded - or you could look into Root Motion and make the character only spin around in prone… if you do that look up the prone IK so that the body can conform to the floor.

All that said you have to match the style of the pack you purchased to make full use of it.
So if you have states,
The possibly worse case scenario involves a 380 walk (split in increments of 45deg) that’s 8 different animations per locomotion state.

8 for idle of you want to nitpick.
8 for walking
8 for running

8 for crouch idle
8 for crouch walk
8 for crouched run if you add that.

8 for prone
8 for prone move
8 for prone run if you make an MGS style game…

The same 24 states are likely required for at least 3
weapon types: long gun, short gun, and melee.

that’s easily a good 150 animations you need to create and implement for a decent motion system.

more if you add things like sneaking that change the root motion of things.

And that is basically why Bone IK is important.

If your animations cannot adjust the position of the gun via the IK bones you will need to go through and manually edit each and every animation to adapt it on a per character basis. That’s likely another set of about 72 animations and it gets pretty cumbersome.
set up and understand Bone IK first if you have multiple characters, then be mindful of it while animating the gun states so that you don’t have to backtrack.

Keep in mind that if you just take your basic walk/run and layer the upper body to a new montage you’ll be running into problems with hit state and basic logic. Is the character running or shooting? Which state do you blend your reload to if your arms are those of a default walking space because you are overwriting the top portion montage that makes you go back to the proper weapon?

Sorry to Necropost but i see this isn’t THAT old relatively speaking. By the way I’ve seen your name a few times pop up when googling problems so thanks for posting answers on the forums it makes it a lot easier for the next generation to learn! Is there anyway you could post a screenshot of a snippet of your anim graph on how you handle different states as you mention above?

At this point this anim state is a year old.
locomotion.png

the sates them-self work with internal states like this:
LocomotionSplitState.png

You can refer to this video for how nested state machines can work alternatively
https://www.youtube.com/watch?v=J-GrGKZ0jGM

https://www.youtube.com/watch?v=mcqgnV55s_o

Here’s a demo of our system which works in first person and third person. The logic of the guns itself is driven by the Logic Driver plugin, not by an animation state machine.

I’m trying to create something that uses as few animations as possible and repositions everything with IK in order to save time animating.

I plan on having basic stances,

One Handed for things like pistols
Two Handed for things like rifles
Shouldered (For things like rocket launchers, in case Two Handed doesn’t work),
Chainsaw Grip (For things like miniguns, Smartgun from Alien, or other giant heavy weapons),
Fists,
Holding Object,
Holding Sword

Each one has its own set of aim offsets, default equip/unequip animations, and idle poses. A weapon can use the defaults but can also override each one if needed. Each weapon also has hand pose overrides. I use a layered blend per bone on the fingers, attachment bones, and IK offset bones. This makes it possible to reuse the common two handed idle pose for every two handed weapon with different hand poses. There will be cases where it doesn’t look good and a custom one for the weapon can be used where I adjust some arm positions.

In the video you can see that even the reloading animation works decently. I use animation curves to control how IK controls the hands. The hands are also procedurally placed relative to your eyes so as you look around your gun follows. And each gun can control the offset relative to your eyes depending on if you’re looking up, forward, or down and be repositioned depending on what looks best for the gun to make it look nice in first person. When the character’s hand reaches down towards the body to put away the magazine, it’s actually using the animated position, not the procedurally placed position, and this blends smoothly. I also use an anim curve to influence how much the aim offset is actually contributing, so during reloads, it can actually have less influence to prevent the gun from being in janky positions during the main animation where we can’t guarantee that the hands will be in a safe idle pose.

I also apply other layers of positioning on the hands, like when you walk, your gun sways, or when you jump or take damage, or recoil, it moves. I can also easily position it for VR controls. And the gun animates nicely in VR because it takes less influence from the procedurally placed location at times.

I’m currently working on getting it to work with locomotion as well. I’m actually creating a locomotion system that’s simpler based on a combination of ALS V4 and V3. It’s not quite as nice, but my aim is to create something that doesn’t get in the way of first person controls and all the head and hip bone positioning we have to do. And we’re hoping to have many monsters on screen so a simpler animation system may be good. Or I might even just straight up use ALS on monsters while I use my own anim BP on the player.

MostHostLA’s comment is making me reevaluate if I want to create walk cycles for each stance since it can be a struggle to get my guy to look good while walking. It looks fine in first person, while in third person his hands look a tad robotic. I could try procedurally moving the hands more in third person and less in first person like I am now.

It’s hard with crouching, especially. The best crouching animations have the character bent over forward more than when upright. And when you start walking, your legs raise up a bit, and the body is leaned over even more.

However my character’s animations are all built for the upright position. If you simply do layered blend per bone on the hip, his body just stays upright when crouched which looks bad and makes the character have a much bigger height than he should. I plan on doing more work where I measure the offsets of the hips relative to the head after locomotion, and then do a bunch more IK to reposition things so the angle of the upper body is preserved from locomotion while still reusing the upright pose that was animated for the weapons.

I also have to push the pelvis back in first person so as you look down, your vision doesn’t clip into your body. Your eyes stay stable as you look around. The camera isn’t actually connected to the head. The head moves to the camera, which will work good for VR as well. This way the aiming and movement feel precise like a first person shooter, and not floaty like a lot of other first person examples where the camera simply attaches to the character model.