How i can change body rotation on animation play?

I have one player

  • I use mecanim of unity.
  • have 3 Base layer.
    1.base layer
    2.TopBaseLayer
    3.BottomBaseLayer

question.
1.I wan’t to change rotation of “top body” on mouse look left,right,top or bottom.

I use mouse look of FPS unity script it don’t work,because it have change all body not top body.

If you have Unity pro, you can use the built-in IK.

Put a avatar mask on your TopBaseLayer and check IK Pass.
For the mask, Select only the upper body part if you are using a humanoid rig or select each transform that you want to affect if you are using a generic rig.
On your GameObject you will have to create a monobehaviour script and define the message callback OnAnimatorIK
see doc for more information:

If you don’t have Unity Pro you will have to find an IK plugin on the asset store or you could tweak the mouse look script and rather than applying the rotation on the root transform you could apply it to upper body transform.

Best regards,

oh thank you.
i have one problem.
On i add mouse look script to spine of model and change Axes is mouseY,on play model can change on mouse Y but model will return to transform default animation not change to new transform.

Hi nscyber,

One thing I forgot to mention is when you modify a transform driven by the animation system, either legacy or mecanim, you need to write you script code in the void LateUpdate() callback, otherwise your new value will be overwritten by the animation.

see doc

Best regards,