"Play Animation" Stops character movement
I set up an AI character than can run around and search for me, I set a "Play Animation" so that when I shoot it, it reacts to my bullet hits, it plays well and everything, the problem is that after the animation, my character's movement animation stops and it starts sliding around on the map.
asked May 19 '15 at 08:49 PM in Using UE4
The Play Animation node isn't exactly smart in the sense of recovering and resuming.
I'd recommend checking out the Animation Blueprints. They're much much more robust and user-friendly when it comes to things like this (switching states and then resuming after some logic is assessed).
answered May 20 '15 at 12:49 PM
TLDR version at bottom. =)
All State changes are driven by transition rule, either going false or true.
Transition rules are the arrows you see between 2 states. Sometimes they are both ways. If you mouse over the "circle", you will see the transition rule's view, and double clicking on it will let you see it clear.
If you check Anim BP's Event Graph, you will see that "Is In Air" is constantly checked every frame. ın the same event graph, you see that we use "Get Pawn Owner", then it's movement component. Movement components got a function, and it is called "Is Falling", which is determined if the character is currently touching on a ground, aka a static mesh that blocks him. This little guy is connected to "IsInAir" variable and the moment "ıs Falling" is true (Aka mesh not touching to anything below that stops him from falling), the IsInAir variable also becomes true.
If you check the basic Unreal 4 skeletal mesh Anim Graph, you will see that, in the first transition it asks "Is in Air?". If it is true, then the mesh starts to play the Jump Start animation. At the same time, you have pressed jump, so it mesh also jumps up, which causes you to see both mesh animation and raising up simultaniously, giving the feeling that it all happened because you pressed the jump button.
This is how generally things work. Animation BP updates itself every frame to check the situation of its variables and change the states accordingly to the transition rules between.
Let's give it a simple example;
Imagine your mesh got one Idle Animation, and one Battle Stance Animation, aka a second Idle Animation that you want to switch between whenever the player is in battle.
Your Player Mesh would have a variable, a boolean called "IsInBattle". Let your Anim BP have a variable, a boolean called "IsFighting?". Names could be same, but let's not confuse it now.
In your event graph of your Animation BP, you would get "Try get Pawn Owner" -> "Cast to Mesh" -> "Get IsInBattle" Var -> Connect it to "Set IsFighting?". Basically what we have done is the same thing you see in the basic Mesh Anim BP, the only difference is we are not checking with IsFalling, rather getting the variable IsInBattle and connecting it to IsFighting?.
Now, in the Anim Graph part of your Mesh, first create a State Machine and connect it to Last Animation Pose (I think I remember the name wrong but its that mannequin guy node). Double click on your State Machine. It will have an "Entry node" at beginning. Now create 2 "States". Call one "Idle", Other one "Battle". First connect the Entry to Idle State, then connect "Idle" to "Battle", lastly connect "Battle" to "Idle" aswell. If you do this correct, you would see two arrows, with two transition circles.
Also don't forget to add one animation to each Idle and Battle States by double clicking on them. =)
Get inside the "Idle -> Battle" transition rule and get "IsFighting?" var and simply connect it. Do the same for the other transition and make it "Is Fighting + NOT".
If you play now and set the boolean var of your mesh which is called "IsInBattle", you would see that your mesh is going from one pose to another depending on the variable.
TLDR version : Watch Unreal Engine "Creating Player Mesh from Beginning" tutorial at Youtube. It explains all. ^^
answered May 21 '15 at 07:44 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here