Smooth rotation on animation

Hi everybody !

I really need your help for that problem, i’m working on it since about 2 month now and i cant find how to make it work.

I simply do a bone rotation to aim a gun toward a target. So i do something like that :

    void LateUpdate() {
        spine.rotation = target.rotation;
    }

Okay ? Nothing hard here, you will notice that i use LateUpdate to override the mecanim animations. And then it work perfectly… but not smoothly, so my problem is :

How to rotate the spine smoothly and keep overriding the mecanim animation ?

I already used something like :

void LateUpdate() {
    spine.rotation = Quaternion.Slerp(spine.rotation, target.rotation, Time.deltaTime * 5f);
}

But it just dont work, the rotation is jittering.

Can i have some help with that ? Thank you so much !

I’m not sure on that but you should probably save your current spine Rotation in a separate variable and use this as your current Rotation instead of spine.Rotation.
As you know you have to override the Mecanim stuff with LateUpdate. therefor your current spine Rotation won’t be the same as you’ve set in the last LateUpdate. Hope you get what I mean but this is just a guess.
Like this:

void LateUpdate() {

     spine.rotation = Quaternion.Slerp(myRotation, target.rotation, Time.deltaTime * 5f);
     myRotation=spine.rotation;
 }