I’m trying to implement a “running” state into an animation blueprint.
The blueprint and its state machine work fine in the debug view and in the preview viewport:
The states get set correctly when the character starts running or walking and the preview viewport displays
the right animations when the running/walking variables are set.
However, the character always plays the idle or the walking animation in-game, but never the running animation - even when the state machine of the character’s anim blueprint is in the correct state at all times:
The screenshots show the blueprint debug view when the character is supposed to be running, but only walks at a higher speed in-game.
What could I be doing wrong?
Are you sure your IsWalking/IsRunning variables are being updated by the anim event graph properly? That is where I’d look first.
Well, as far as I can tell, they are - the state transition rules use the variables to allow the change into the running state and the yellow execution line updates correctly when looking at the event graph in debug mode when the character starts running.
The changes also work on both the server and the client.
The debug view even displays the animation as being played when the character is running, as shown in the second screenshot…
I was able to set up a simple state machine transitioning from idle to walk to run based on speed rules set up in the transition rules as illustrated below:
Let me know if this is what you are trying to achieve.
Thanks for the reply and apologies for my slow reaction.
I set up the animation blueprint just the way you did now - that’s exactly what I’m trying to achieve and your way of using the speed variable directly in the transition rules is much more elegant than my boolean variables.
However, the problem remains the same: The blueprint works perfectly in the preview window and reacts to the different speeds by selecting the correct animations. In-game, the only transitions working are the ones from idle to walking and from walking to idle.
Maybe the problem lies in the way I set the speed for the character? I do it like this in the pawn blueprint and, although the animation is not updated, the pawn does move faster when pressing the sprint key:
When printing the current speed (= length of the movement vector), the value appears correct and, since the walking animation is working, the blueprint seems to be able to use the vector length. For the idle/walk transition it only has to determine if the vector length is greater than or equal to zero, so maybe just that comparison works and the vector has a different (normalized, maybe?) length in the animation blueprint?
Thanks for the help!
Okay, I identified the problem. As usual, it was caused by incorrectly using replication.
The character movement component is appearently not being replicated by default. When setting the walk speed on the server, the pawn does move faster but the walk speed on the client’s movement component is not being updated.
Although the pawn moves faster, the client and the server then have different (asynchronous) ideas about the length of the character’s movement vector. The printed value is the length of the vector:
I fixed the issue for the moment by using the speed (>/== 0) for the transition from idling to walking and a replicated boolean variable for the transition from walking to running.
Thanks again for the reply to , your comment pointed me in the right direction. You guys are doing a great job here.