- Home /
Rotating Armature During Animation
Hello,
Just as the question asks.
The problem is that I can't seem to Quaternion.Lerp or Slerp while my armature is doing an animation. I want to rotate JUST the armature, as it's primary purpose is an aesthetic.
I've tried keeping the Slerp in LateUpate() method as well, but to no avail. The Slerp starts and then gets shut down every frame.
The ultimate purpose of this is to use ONE walk animation instead of making 8 for each of the directions.
My code :
void PlayMovementAnimation()
{
if (gravity.isGrounded)
{
switch (actionManager.movementState)
{
case ActionManager.MovementState.Creeping:
//Play Creeping Animation
break;
case ActionManager.MovementState.Normal:
if (!parent.parentObject.animation[walk.anim.name].enabled)
{
Debug.Log ("playing");
parent.parentObject.animation.CrossFade(walk.anim.name);
break;
}
else
break;
That method is in the Update() method.
Another code snippet:
void Movement()
{
switch (movement.direction)
{
case MovementManager.Direction.Forward:
root.transform.rotation = Quaternion.Lerp (root.transform.rotation, rotationScript.forward.rotation, Time.deltaTime * rotationScript.rotationSpeed);
break;
case MovementManager.Direction.ForwardLeft:
root.transform.rotation = Quaternion.Lerp (root.transform.rotation, rotationScript.fowLeft.rotation, Time.deltaTime * rotationScript.rotationSpeed);
break;
That method is in the LateUpdate() method.
The only solution that I can think of at this point would be to either rotate the whole model (NOT a viable option) or AddMixingTransform() all except the root bone and rotate the root (I'd lose root motion, though).
Thanks for any help!
Bumping this question.
Upon further research yesterday, I found that it's not possible to (S)Lerp a root bone or armature during animation, but it IS possible to increment it.
Incrementing makes it a hell of a lot harder, though. Especially finding the shortest distance between two angles and deciding whether to go negative or positive with the increment.
Does anyone have a solution for shortest-angle incrementing?
Answer by Lairinus · May 20, 2013 at 10:47 PM
The answer was SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO incredibly simple that I'm ashamed to even post the answer here.
For anyone who wants to know, the only thing you have to do is AddMixingTransform the root bone. After that, it rotates no problem in any direction.
I just went through making like 12 failures of angle interpolation scripts in order to do this, and 3 days later I try to do the most simple thing out of desperation and it works. I thought locking the root would have the inverse effect.
Your answer
Follow this Question
Related Questions
Slerp Rotation Problem 2 Answers
how to rotate an object smoothly 2 Answers
Multiple Cars not working 1 Answer
i want to get my to cube to rotate 90 degrees on the x-axis as it jumps 0 Answers
Quaternion Smooth Rotation 0 Answers