0
\$\begingroup\$

I want to rotate my character's chest, so its looking direction will be visualised correctly.

But I think that the animation controller doesn't let me.

I logged its rotation before and after I set it, and after setting, it's correct, but next frame before I would set it, it's always snapped back.

How could I make my character's animation transformed, based on its looking direction?

This is the code:

Debug.Log(Chest.localRotation.eulerAngles);
Chest.localRotation = Quaternion.Euler(90, 90, 0);
Debug.Log(Chest.localRotation.eulerAngles);
\$\endgroup\$
  • \$\begingroup\$ You need to show us your code in context. Is this in Update, LateUpdate, etc? Remember you should always share a Minimal Complete Verifiable Example: enough information about your problem that we can reproduce exactly the issue you're experiencing in a new empty project, so we can test proposed solutions to be sure they actually solve your problem. \$\endgroup\$ – DMGregory Jul 12 at 19:11
  • \$\begingroup\$ It's in Update, sorry I was rushing, and I thought that "next frame" was a good enough implication. Hmm, maybe it should be in LateUpdate? Yes, it was overridden because I didn't set it in LateUpdate. Sorry for nuisance and thanks for guiding me :D \$\endgroup\$ – Tudvari Jul 12 at 19:14
1
\$\begingroup\$

Animations set the rotation between Update and LateUpdate.

If you want to apply a modification to an animated pose, you need to apply it in LateUpdate, so it applies "over" the animation, rather than being replaced by it.

Note that if you want to persist some orientation from frame to frame (eg. for a lerped blend) you'll want to store the calculated value in your script, so it doesn't get stomped by next frame's animation tick before you can update the future frames using this historical data.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.