Setting a animation class with a custom variable

Hello. I have a problem with setting up the animation class in my BP. I am trying to implement animations to my gun system. But each gun has to have a different class and it would be easy and fast to just make it a variable because I can change the variable with each weapon and not worry about it too much. My question is why this isn’t working…

whatafak

It should work right? All I’m doing is setting the anim class to a specific object (in this case, a animation blueprint), yet it doesn’t work. Why? Am I doing something wrong? Please help and thanks in advance.

Hey @nick-0!

So I think the problem here is that there isn’t an ABP created to be loaded in as the anim instance.

I would actually suggest, for this, using each gun as a new actor and using attach actor to the socket on the player, and setting a reference like “CurrentEquippedWeapon”. That way you set each ABP to each gun’s skeleton in the editor, and simply create/destroy actors which is much better than having a bunch of unused ABPs in memory! :slight_smile:

All the weapons are seperate, but they are a child of the weaponBase actor. I’m just asking if it’s even possible to do it this way or do I need to take the long way around?

Well, if by the “long way around” you mean creating an ABP for each weapon to match its skeleton for the animations, and then attaching it in each actor blueprint in editor… That is 100% what I would recommend.

It’s an extremely stable method that is simple, and while it seems like it would be the long way, trying to set them in the manner you are is going to have the high chance of causing bugs and will end up being very complicated and time consuming, making that the actual long way around! :slight_smile: