Hi all. I have been following the tutorials and I have managed to get my character to move via input. It is the basic setup using blendspaces, whereas the character will start in the idle position and as you press up he will then walk and eventually run. The next functionality I want to add in is a roll mechanic but I don’t really know how to go about doing it. When I tried last my character would roll but he would be out of position and as soon as he stopped rolling it would translate back to the original position where my character ended running?
I set up the roll animation via a keypress and it is not linked to the idle, walk, run blendspace at all. Any pointers would be greatly appreciated.
I am not much of an animator, but what you’ve described sounds like an issue with root motion. In a root motion error, the character’s mesh would leave it’s capsule collider during certain animations (such as rolling), and then snap back to the origin (wherever the capsule collider is) when the animation completes. This, of course, both looks and feels weird in a player-controlled character.
There are a couple ways to fix such an error, but the easiest one is probably by adjusting the “Force Root Lock” bool, and setting it to “Anim First Frame”. This doesn’t always work, and it’s success depends on how exactly your skeleton and animations are built. What you want, in the end, are animations that occur “in place”, or where the mesh animates 100% inside your character’s capsule collider.
The next thing you’d want to fix is to move your roll animation into your AnimBP, adding the roll anim as a new anim state tied to your idle/run blendspace. You’ll need to create a new bool that, when set to true, will transition from the run state to the roll state. Inside the roll animation, it would be necessary to create an AnimNotify event that will reset the bool to false near the end of the animation (this is to ensure that the animation doesn’t loop - if the bool were true when you go back into the run state, your character would simply roll again). When the roll animation ends, you can transition back to the run state. Finally, you can change your keypress input to simply set this bool to true, causing your character to initiate a roll animation whenever the key is pressed.
This doesn’t get the character actually rolling forward in world space, so what I do in Ethereal Legends is add a small physics impulse to the character in the direction of his forward vector, so that he’ll kind of burst forward when you roll. This creates the illusion that roll actually moved the character forward, and does indeed actually move the capsule collider a small amount in world space. How you handle this will greatly depend on your game and it’s needs, so do whatever feels best for your gameplay.
Finally, spruce it up with a tiny bit of screen shake, a good sound effect, and maybe some dust particles or something for a bit of extra flair.