- Home /
Avatar animation - OnAnimatorMove
Hello, I am kind of a newbie in Unity and currently I am solving quite confusing thing as follows.
I have a .fbx file with animation of avatar doing strafe right, which I've added into animator as a state.
When importing animation, I've checked 'Bake into pose (XZ)'. Doing so I have avatar which when key is pressed makes strafe right, more or less about 0.84 on X axis and the root motion which does not move itself.
Then I've decided I want the root motion to move with avatar and to handle root motion by myself using OnAnimatorMove() method. So I left unchecked 'Bake into pose(XZ)' setting in animation import and write simple code to actually move the avatar during strafe right.
The simplified code would look like that:
transform.position.x += animator.deltaPostion.x;
Unfortunatelly doing so I have the avatar doing strafe right, but only for like 0.6 on X axis. More over this distance is varying each time - sometimes 0.47, sometimes 0.56, 0.67.
I would really need the avatar to behave like in the first case when the distance is always same 0.84, but can't figure it out how to do it in OnAnimatorMove() method.
Am I using deltaPostion inapropriatelly?
Thanks in advance.