Hello,
Root motion seems like a powerful tool to allow artists to do their animation where the Controller lose control and yet ensure the mesh/capsule will follow the movement in-game (while colliding). But I still have various trouble with it. The last one is about pitch/roll.
First, what I am trying to do.
I am still at the prototyping phase, trying various simple things to ensure the basis will work once the project gets more complex. For that, I use the ThirdPartyExample and AnimStarterPack assets.
As you probably know, the origin of the UE4SkeletonMannequin is at its feet, as I would expect. But, since the origin of the Capsule is at its center, it means the Mesh needs a relative transform location of around -90 on the Z axis to touch the ground. That will have its importance later.
I am now doing a “fall on the ground” animation. For that, I simple took an idle animation (Rifle_Idle_Hip) and rotated the root by 90° face first. Yes, the character clips badly into the ground, meaning the capsule collision will probably have it floating a bit. That’s fine, that can be adjusted later when the animation becomes a bit more complicated.
I will apply this on an NPC character when I shoot him. So I turn on root motion, create an animation montage, make sure it is also on for the Animation Blueprint of the NPC and run that when needed. The animation applies, but the rotation is all wrong. The point around which the character seems to rotate might be its feet at first, but it doesn’t stay so, and after a while it is strangely floating in the air. (Note: I am only applying a rotation on the root bone in the animation, no translation.)
I don’t have a video capture software, but to give an idea, here are three screenshots. Start is the original state, Middle is during the rotation and End the result.
As far as I can see, this is not linked to the collision of the capsule. The capsule is still way above the ground and modifications to its size don’t change anything.
On the other hand, if I remove the transform location of the mesh so that it’s origin is in the middle of the capsule, the rotation happen as expected, with the capsule rotating neatly around its center and the body rotation around the center of its feet. Unfortunately, I cannot work with that as it means the character is a meter or so above the ground.
Interestingly, once the montage is done and the state machine and animation blueprint take over, the character stays floating horizontally. I would have expected gravity to pull them to the ground, as it does if they spawn in that position.
Another interesting fact is that, if I shoot my enemy four times, doing a full turn, they will end up back on their feet. (And two times have them on their head.) So, while the rotation is not what I would expect, it’s not complete nonsense either.
My impression is that the engine is trying to calculate the movement of the capsule based on the movement of the mesh, and failing badly at translating the rotation center.
I haven’t looked at the C++ to confirm my assumption, as I wouldn’t know where to start. (Right now, I’m going blueprint only for prototyping. C++ is coming later.) First, I wanted to check if anyone had already encountered that issue and if I’m not missing something obvious.
Does anybody has an idea how to fix this?