Chaning animationBP on weapon Selection

hey guys
I created a system and I want your feedback to know what are the drawbacks of that system.

the general idea is that each weapon has its own animationBP and when the character equips that weapon it sets that animBP as the active one.

but how i actually implemented it is by making a map of animBP inside the character class and use the name of the weapon to search for the associated animBP and activate it. (don’t know if that’s the best practice for it )

what do you think of that method? what are the drawbacks ? are there any better ones?

Hello @Remous1 ,

I think, it can be a problem to maintain in the future since each one weapon type is handled by single anim bp (but maybe that is the only thing that work for you, I don’t know about your implementation).

I’m also having a kind of similar system, where I have 3 weapon type (If Im equipping a 1H then I will play 1H anims, if 2H then 2H anims). I’m just using only 1 anim bp to handle all of that.

I don’t know if it is better or not, but I think its easier to maintain in the future since I only need to modify 1 anim bp instead of 3. Here is how I handle it.

I create an enum for handling the weapon type and put that enum in the Weapon Actor.
image

And in the Anim BP, I do a Blend Pose By Enum, using the Equipped Weapon Type.

i used to do that in the past but the animBP would become so complicated as i progressed forward and harder to read and maintain.

say you want to add a new weapon in the future …your way you will need to keep on editing and adding more to the current ABP which is making it more complex.

if you do it my way you wouldn’t need to care about anything. you will build an ABP from scratch focused only on your weapon and it’s animation.

I see, if you think your way is more comfortable for you, then just go with it. Since mine is just a simple thing, it will be easier to maintain if its in one Anim BP for me.

I go with “Universal” states in the weapon config. Those states drive the flow logic in the animbp.

I also use left hand IK (FABRIK) so I’m not having to add custom animations with each new weapon. Each weapon atm is a child class in a hierarchy (weapon → AR/SR/SMG etc → M416). The skeletal mesh is a child of a scene component. This allows me to manually move the mesh around in the view port to determine its right hand attachment position. Then I do left hand IK vector offset in a config.

Here’s some old vids I did that cover it.

linked anim layers is the way to go, soo much cleaner

1 Like

i think that’s definitely worth checking out thank you

never tried it tbh …gonna try it out thank you <3

Great link and approach, yet I feel I need to note that everything “linked to” and referenced by a class is loaded into memory when that class is spawned.

For example, If I have 100 animations for my character, all 100 are loaded into memory on every client in the game. Any linked assets and their animations as well.

If I have 2 characters and they both have 20 unique anims each, then I’m loading 140 into memory.

If I have an audio component that references 50 wav files… 50 loaded.
Emitters and their referenced FX…loaded.

At some point you need to look at ways to reduce tech debt. How much, where and how is determined by your game. How much RAM do you need to stream your level and load/unload other assets? How large and complex is your game world? How fast can a player move from one area to another (think streaming distance)? How many dynamic and networked actors do you have in your world? e.g. Anything interactive, destructive etc.

My use of IK for hand placement is a way for me to take a base set of animations and re-use them for multiple weapons. This reduces the memory needed for my character.

I’m working on a 100 player game with 8x8Km game worlds and thousands of interactive actors + vehicles.

1 Like

well i use soft object references and async load but this is true no matter how you store your animations.

that said linked anims isnt to replace procedural IK but in addition to, for instance id use your method of IK for the left had position but linked anims for completety differrent stances like, pistol, rifle, melee etc

id use your method of IK for the left had position but linked anims for completety differrent stances like, pistol, rifle, melee etc

Is it worth the additional work, class instance load, and complexity?

My weapon Gripping for the most part is handled by IK (left hand offset). Right hand is manually handled by adjusting the skeletal mesh in the class. With an additional Vector and Rot var I can make the left hand IK adjust to different modular weapon grips. Vertical, angled, half, thumb etc. My characters are modular (skeletal mesh merge). I just swap out left hands as needed.

AR, DMR, SR, Shotgun, SMG and some LMG’s work fine with a single hip and ADS upper body aim space. Depending on your locomotion stances (standing, crouch) you can typically still use the same for both of these stances. Prone obviously needs a different pose.


well i use soft object references and async load

My understanding of the engine is any animation you have “retargeted” to your mesh is autoloaded when skeletal mesh is spawned. Regardless if your animgraph only uses a single animation.

image

Everything is the asset browser is loaded too. If it wasn’t you’d see hitching and jitter as it was loaded. Basically memory allocation and disk read delays.

i think its worth it but to each their own,

i like linked assets because each one is a separate asset and you can always add more without changing any code.

its a new system so im no expert on the performance but im pretty sure its better, again each link is a separate asset so rather than load it all im sure it just loads what you use.

i havent had any hitching in my usage and i use 5, rifles,pistols,melee, unarmed and item. item i might expand further into more categories

its what lyra uses if you want to check it out

i think both ways are good on their own way because if you want more flexible and advanced animations for each weapon then linked is the way to go but if you can just manage with an ik then it’s definitely more performant . correct me if I’m wrong please

You shouldn’t see hitching/load issues until you start working with large projects. Like open world battle royale… MMOFPS. For Arena and small world games the only hit you could run into is higher min system requirements.

What I’m doing is going to require 16GB on both RAM and VRAM. No way around that.

World loot is upwards 125 different items… most of which are guns. I estimate roughly 10K of these items spawned in the world. Each loot pile will range from 3-6 items ± ammo for spawned weapons. That could mean upwards a thousand newly replicated actors in a city you are now just exploring. There’s also 50 vehicle spawns, destructible assets, projectiles (no hitscan weapons). Basically PuBG meets Tarkov PvE.

With open worlds you aren’t fully loading the map and all its actors. You only load what you need based on streaming distance and network cull distance. As you move into other areas old areas outside streaming distance are unloaded. Not a huge potential hit if your movement speed is reasonable. But once you get rolling with vehicle/flying speeds everything changes.

Anyway, I’m definitely going to dive into modularization. I’ll have to do some testing to see if its worth the added complexity.