Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Help Setting Up AnimBP to Check if Holding Weapon


I'm having some trouble configuring my CharacterAnimBP to include different animations when holding various weapons. I'm currently only working with one weapon and if I can get it working I'll know how to setup for the rest later. So far I have:

  1. Created a blend space "Jog_Holding_AR" for the animations related to this weapon.

  2. Added a new state "HoldingAR" in my state machine.

  3. Mapped the blend space to the new state

  4. Created a bool inside my weapon bp "SK_GunTEST" that sets it to true once the weapon has been picked up.

  5. Attempted to cast to this bp from inside the anim bp "CharacterAnimBP".

I'm sure I'm overcomplicating this but all I'm trying to do is be able to access this boolean from the anim bp so that I can check if it's true or false and update the animation accordingly. From what I found online it seems the only way to do this is by using a "cast to" node, but the problem is I don't know how to set up the object portion. If there is a better method or solution to my current setup please let me know, any help would be appreciated!

Product Version: UE 4.19
more ▼

asked Aug 24 '18 at 03:16 PM in Blueprint Scripting

avatar image

63 8 12 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first
  1. Don't use different states for holding different weapons.

  2. Use an Enum to define which (if at all) weapon a character is holding. Make a Interface for the communication between the AnimBP and the pawn. This will make it easier if you have different pawns.

  3. With that enum simply use a Blend by enum animation node to pick the correct animation for the weapon.

  4. Use a Layer blend by bone node to split your animation system to the upper and lower body. That way you don't need a separate blendspace for every weapon AND every movement type:

alt text

You will also need two state machines, one for the upper and one for the lower body.

more ▼

answered Aug 24 '18 at 03:34 PM

avatar image

196 6 6 15

avatar image Skisma Aug 24 '18 at 04:01 PM

Thank you for your solution! However, I think this may be too complex for my game. My apologies, I didn't give any context there. The game is going to have a blocky art style so fine details in animations aren't going to matter too much. Also, only one pawn as it's single player and there will only be 3-5 blend spaces I'll need for each weapon 'category' (ARs, Pistols, Shotguns, Rocket Launchers).

avatar image Takao_ Aug 24 '18 at 04:16 PM

If you split your animation system in upper and lower body you don't need 3-5 blend spaces for each gun. You will only need 1-2 (idle / moving).
Then you can also use animation from different sources for your lower and upper body. For example use the Paragon animations for your lower body.

avatar image Skisma Aug 24 '18 at 04:23 PM

Hmm I still think that's overkill for what I'm trying to achieve but maybe it'll come in handy later down the road! The game is going to be very simplistic and use a minimal amount of animations. I was taking about 3-5 blend spaces total—not for each weapon, that would be insane! haha

Would you mind posting a screenshot of the event graph or do you have a tutorial that you used for this that you could link to?

avatar image Takao_ Aug 24 '18 at 04:33 PM

My event graph woun't be very helpfull for you, because I do my calculations not in the animbp but in a seperate component. Or do you mean the state machines?

avatar image Skisma Aug 24 '18 at 06:41 PM

Sure, seeing inside the state machines might help. Honestly though there is a lot going on in your's that I'm not familiar with, it would be easier if I just had a method to access the isHoldingAR boolean I created from within my anim bp.

avatar image Takao_ Aug 24 '18 at 06:50 PM

State machine lower body: alt text

Idle state (upper body): alt text

Moving state (lower body): alt text

Note that I currently don't have any "to move" or "to stop" (= start / stop moving) animations implementet and therefore not states for them.

Getting a variable from the pawn is just casting the owner (Try Get Pawn Owner()) to your class and then getting the variable. Or use an interface.

avatar image Skisma Aug 24 '18 at 07:06 PM

Thanks for your continued help! So the only thing is that I'm not getting the variable from my pawn, but instead my weapon blueprint. This is what's making it hard as I can't figure out what to attach to the object of my 'cast to'. Anything that has a reference to 'self' won't work because it's not inherited from the pawn class.

avatar image Takao_ Aug 24 '18 at 07:13 PM

??? Adding a variable to a weapon to check if it's picked up doesn't make much sense. There is a function GetOwner() which should be set once that weapon is picked up and set to null, once droped.
If you want't to know if the actor has any weapon equipped, you can make a function, that checks if the pawn's variable EquippedWeapon (or similar name) is null or not. Because when you pick up a weapon, you need to store a pointer to it in your pawn.

avatar image Skisma Aug 28 '18 at 01:44 PM

Ok I figured this out over the weekend and it was so simple! Sorry, I'm learning as I go so I was going about this backwards. Initially, I was trying to store the boolean locally inside my weapon bp, then trying to cast to it from my character bp to try and reference it somehow. Once I realized the solution I laughed at how simple it was. I got it working by creating the bool inside the character bp, then casting to it from the weapon bp and setting it to true once picked up. Adding images for anyone who might come across this with the same question.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question