Overriding animation.

I am trying to make my character turn at the waist towards a target rotation, using Slerp. Everything works fine when animation is off, but when I turn it back on I get jitter.

As a test, I did this:

function LateUpdate(){
	lowerSpine.transform.Rotate(90,0,0);

}

With animation off this spins in place forever as intended.

With animation on, this turns slightly, and then does nothing.

Why isn’t this working?

because animations contain information about the transform data of any bone and as they animate, they enforce it.

You would have to have an own system that handles the animation that allows you to alter data temporal-statically I think

In unity thought there are the animation layers. You might want to checkout if you can use them potentially.

http://unity3d.com/support/documentation/Manual/Character-Animation.html

At the bottom of this page it says that animations can be overridden through scripting if placed in late update, in fact its example is almost exactly what I am trying to do.

So I know its possible, but this just isn’t working and I cant figure out why.

Any ideas?

Well, you’re turning it, but the animation is taking it back in-between rotations. When the documentation says it can be overridden, it was referring to the ability to set the bones’ positions by hand every frame to take over from the animation.

If all you’re doing is rotating, you’ll end up with the body just stuck at 90 degrees further but doing the same animation.

To illustrate, here’s what happens:
Animation frame
Rotate 90 degrees
Reset to next animation frame
Rotate 90 degrees
etc…

Ooo… I see. So how should I do this then? The headLook controller on the unity blog is similar to what I am trying to do, but the code is slightly over my head and I can’t really tell whats going on there.

Increase a variable by the amount you want rotated and then assign that one to the model by either saying transform.Rotate(variable) or transform.eulerAngles = variable;