- Home /
Question by
AndyNeoman · Sep 16, 2017 at 11:25 AM ·
c#animationroot motion
account for rotation in scripting root animation
https://docs.unity3d.com/ScriptReference/Transform.Rotate.html
I am using this method to move an 'inplace' animation. It works fine if the players rotation is 0,0,0,0 but as soon as I rotate the player the motion is not in the required direction.
This is expected as the animation moves along the set transform.z position but how do I account for the rotation angle so with the animations direction is correct.
Comment
Best Answer
Answer by AndyNeoman · Sep 16, 2017 at 03:16 PM
Fixed this. the forward of the transform needs to be accounted for too on a rotating object.
transform.position += transform.forward anim.GetFloat("RootMotion") Time.deltaTime;