Announcement

Collapse
No announcement yet.

How do i Play Attack Animation While In Air?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do i Play Attack Animation While In Air?

    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.

    Thanks in Advance.

    #2
    Its probably a easy thing to do but i am probably missing something.

    Comment


      #3
      Hi!

      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.

      Is that what you're after?

      Comment


        #4
        Here's some images to help.

        Click image for larger version

Name:	VariableTest.jpg
Views:	36
Size:	354.1 KB
ID:	1721332

        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.

        Click image for larger version

Name:	Animation-Graph.jpg
Views:	31
Size:	336.4 KB
ID:	1721333

        Comment


          #5
          Here is how i have mine setup (still not working) the player uses the attack animation in replace of the "JumpLoop" animation i have setup in the state machine.

          Here is what my state machine looks like:
          Click image for larger version

Name:	VxxCl4IwYq.png
Views:	33
Size:	45.2 KB
ID:	1721339

          Here is what i have setup inside the rules defining the attack animation playing:

          Click image for larger version

Name:	9JMa78g2RB.png
Views:	25
Size:	39.4 KB
ID:	1721340

          Rule going from Attack back to JumpLoop

          Click image for larger version

Name:	UE4Editor_71eLRcZHpI.png
Views:	23
Size:	49.3 KB
ID:	1721341

          Here is what the Anim Graph looks like:

          dsClick image for larger version

Name:	UE4Editor_13YHu0Sdel.png
Views:	24
Size:	75.5 KB
ID:	1721342

          Here is what the Event Graph inside the Animation Blueprint looks like:

          Click image for larger version

Name:	81kVmIrYo2.png
Views:	23
Size:	24.8 KB
ID:	1721343

          Here is inside my character blueprint:

          Click image for larger version

Name:	DCZsaEt3B5.png
Views:	23
Size:	28.2 KB
ID:	1721344

          Please respond with any problems you find that i have not done correctly, thanks.

          Comment


            #6
            It's an attack. just use montages. Watch/follow all of this
            https://www.youtube.com/playlist?lis...WLTJ4wiUzEvXis

            Comment


              #7
              The animation is a montage i put that into a default slot which gets called in the anim graph

              Comment


                #8
                I just need a way to call that montage to play when the attack button is pressed when player is in air.

                Comment


                  #9
                  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.

                  Comment


                    #10
                    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.

                    Comment

                    Working...
                    X