- Home /
Mecanim OnAnimatorIK() execution order
Hi there! I can't understand execution order of methods OnAnimatorIK() and LateUpdate(). Does OnAnimatorIK() override the results (I'm doing some custom IK in LateUpdate()) calculated in LateUpdate()? If so, how I can override resulting charachter pose calculated in OnAnimatorIK()? Thanks in advance.
Answer by TonyLi · May 27, 2013 at 02:51 PM
I ran a quick test. I'm not sure the results hold 100% of the time, but here they are:
On the first update cycle: Update -> LateUpdate > OnAnimatorIK
On all subsequent cycles: Update -> OnAnimatorIK -> LateUpdate
I ran 10 trials of 100 cycles, where each cycle reported the time it ran Update, LateUpdate, and OnAnimatorIK. However, OnAnimatorIK just sets IK targets. I don't know when it actually computes and applies the IK.
In this thread, the developer suggested that LateUpdate is the right place to put your custom IK code, but didn't provide many details. If you post the question on the Unity Support forum and an official answer, please let us know!
Thank you very much! I've fixed my code in LateUpdate(), now everything works fine. But I think I would anyway reject of using built in I$$anonymous$$ for my character, because it doesn't always give correct results even for the head (_animator.SetLookAtPosition())