Download

Help with assigning an Input Action to a variable

For some reason I can’t wrap my brain on how to get switching functionality.

I have a ‘Current Weapon’ int variable which switches from one State Machine to another using the Blend Poses node. That works fine. (See screenshot)

On my ‘MyCharacter’ Blueprint EvenGraph I have an Input Action called “Holster” with a press and release.

I can’t figure out how to tie that Input Action to modify my int variable called ‘Current Weapon’. Any suggestions would greatly be appreciated.

Do you ask how communicated between MyCharacter and the animation blueprint?

Yes. Im still trying to figure out how to do that…

d65466ea0b469240afe628c8e3b69fd90a289a71.jpeg

you need cast the player variable and get the int in “Holster”, to set in ‘Current Weapon’.

I’m still a bit lost. I’ve taken a screenshot of what is already setup since I’m using the Starter Animation Pack as my base. I think I need to create another Event Sequence for switching my States like outlined above in my previous screenshot. It seems that you can only have one Event Blueprint Update Animation node. Should I build off of that since that is currently setup with Movement? I tried to make a new EventGraph but apparently you can only use one Update Animation node…

any variable that you put in HeroCharacter can be “get” from node “Cast To HeroCharacter”, like JumpbuttonDowm and CrouchButtonDowm.

I’m new to Blueprints so please bear with me. Here is what I have setup so far:

So ‘Current Weapon’ sets the States; 0 for No Weapon and 1 for Rifle. 1 is the default. (Screenshot 1)

If you click the ‘Holster Weapon’ input key it sets ‘Holster Weapon?’ to True, the Branch checks ‘Holster Weapon?’ and since it’s true it sets ‘Weapon is Holstered’ to true. (Screenshot 2)

If I understand this correctly; ‘Try Get Pawn Owner’ and Cast To ‘HeroCharacter’ checks my character, check the variable ‘Weapon is Holstered’, and since it’s True it sets the ‘Current Weapon’ to 0 which should play my ‘No Weapon’ State. It doesnt.

Thoughts?

yes correct that is how work.

BTW, the second screenshot is a little overthinking but work.
They are a funny node calling Flip Flop that save a lot of spaghetti.

e824377e71f160af2da558c74f2eaebb7df0be0a.jpeg
Change aim by Weapon is Holstered

BTW2 Why dont use a “blend Pose by Bool” ta save the conversion the bool to int in the last part of third screenshot?

Thanks for the Flip/Flop tip! Im working through the Blueprint Essentials, so I’m hoping to get a better understanding.

Based on what I have shown above, is there something I’m missing? When it click the ‘HolsterWeapon’ key nothing happens.

You need “Event Blueprint Update” pin to cast to HeroCharacter. Use the same node that JumpbuttonDowm and CrouchButtonDowm.

Thats the problem. It’s already attached to the Movement portion of the graph, and apparently you can’t connect the Even Blueprint Update Animation to multiple nodes.

You can use secuence to reuse the same node.

Now I got it to work, thanks for your help!

you’re welcome, I feel like a midwife in this process, It was a beautiful bird.