Hello game developers. I am new to unreal game development. Here is my issue:
So i have my character walking around playing animations. Which is fine, but i want a certain Attack Animation to play pressing a button only when player is in air. How would i go about doing that?
In my animation state machine i have a state going from JumpStart to a state called **Attack. **This Attack state has the attack animation to play while player is in air. Any help would be very much appreciated. I would love for screenshots of step by step of how i can accomplish this.
I’m going from memory here. But you need an “inAir” variable or something to know that your character is in the air. So in the animation blueprint that you make from “Event Blueprint Update Animation” you “try get pawn owner”, “Get Movement Component”, “Is falling”. This will return a bool to update your variable “inAir”. Now your blueprint knows if the character is in the air or not. This then can gate your action. When you press your action button there must be a branch that checks “inAir” first. If true then the attack can happen. If false then nothing.
And here’s my animation graph. I did this a while back so I can’t remember what’s going on. But my character can attack while running using this slot. The animation only plays on the upper half of my character’s body.
Drag off the movement component, type air, and see what you find.
alternatively the movement component has/runs a line trace that can tell you the distance off the floor. You could piggyback onto that trace and use a > 0 to determine if you could attack or not.
Note that this will also be true any time you are falling.
if that isnt suitable, use your Jumping boolean or create one if you don’t have one already.
Thanks for all your guys help, i figured it out. I setup the attack montage and used that animation in the state machine going from “JumpLoop” to “Attack” and in the player character blueprint, i created a keyboard action event, i created a Boolean variable called “AttackInAir” and for the Pressed i set it to true and for the Released i set it to false. And in the Animation Blueprint in the Event Graph i cast to my player character Blueprint and for the object, that goes into “Try Get Pawn Owner” and you can access the “AttackInAir” Variable by dragging from “As third person BP” and search for “Get Attack In Air” and from that you can drag out and promote to variable and hook up that up. And of course making sure that in the Anim Graph you setup the slot for the animation montage. That done it for me.