- Home /
Override mecanim animation with manual bone rotation
Hi! I want my character's arms to rotate according to how the right gamepad stick is pressed. This is no problem in itself, however, whenever i apply my animator controller to my character, the bones I try to rotate (in the update function) are not being affected. It is as if the script-controlled rotation is being overridden by the animation that is played. How do I make my script-controlled rotation override the mecanim animation when the player pushes the right stick?
Thanks
Anyone? How about disabling my animation just for the arms? How would I do that?
This must surely be a common problem. Is there no easy solution?
Okay, Update! transform.Rotation seems to not work. However, transform.LookAt works just fine (in the LateUpdate function). This is reaaally weird. Could anyone explain this, or is it perhaps a bug?
It's like Louis explained below - your Rotate was adding a rotation to the existing one. transform.rotation will work too.
Do not do this in FixedUpdate - that is for physics only. Do it in LateUpdate.
Oh, right. I meant LateUpdate there! I understand now. Thank you.
Answer by whydoidoit · Mar 28, 2013 at 05:22 PM
I'm no mecanim expert but it will probably work if you override the mecanim rotations in LateUpdate.
I tried doing that by putting this in LateUpdate() of the bone:
transform.Rotate(0,30,0);
But to no avail. The arm stays put in a rotation of 30 degrees, it does not increment like it should...
If I remove the animator though, that same code makes the arm spin.
That's because animation is setting the rotation in Update and then you're rotating that by thirty degrees, which is always the same. You need to track exactly where you want the arm to be, not just its rotation speed.
Answer by petersvp · Aug 14, 2015 at 12:22 PM
LateUpdate is your best friend for rotation patching. In LateUpdate, you have the Mecanim results, and you must calculate yourself how to exactly patch the provided rotations.
Yes, your 100% custom IK code should go in LateUpdate, and everything you need and OnAnimatorIK does not provide :)
Does anybody know how to send this information through online on Photon? I can get the lateupdate to work but not through a RPC call which sends the information as I want it but not update the rotation. :/
Your answer
Follow this Question
Related Questions
Mecanim 'extra' root bone rotation 0 Answers
How do you manually override mecanim's interpolation with rotations? 2 Answers
MakeHuman - Blender - Mecanim, rotation problem 1 Answer
Mecanim position specific bone 0 Answers
How to convert quaternion to vector3 with specific multiplication order? 5 Answers