Mecanim IK delays with observations
Greetings,
we are experiencing some strange issues when combining observations and Mecanim avatars.
We are using an agent Reset method to make the avatar look at the camera, setting a target transform variable. The avatar has a script with OnAnimatorIK calling SetLookAtPosition and SetLookAtWeight to actually update the mesh. When the animator is set to Normal update mode there is a (variable) delay until the head actually turns.
Here is the observation after the reset:

And this is the expected result:

When the animate mode is set to Animate Physics, the eyes and mouth meshes are updated properly but the rest of the mesh still lags:

This is only visible when rendering the observations, the scene runs as expected on the editor and as a standalone build.
Our current assumption is that on Normal mode the IK solver takes place after all the physics updates, where the Academy runs, so the observations show for a while the state before the complete mesh update. On Animate Physics the IK update would happen on the physics update phase too, so the observations show an incomplete update of the bones instead.
Any hints are very much appreciated.
Alfredo
I also have these problems.
Any news @asolano ?
Hi, @r-lipton
More investigation pointed at the SkinnedMeshRenderer component being updated by Unity in LateUpdate, so the skin is always behind the bones, and only renders correctly at the end of a complete frame.
There seems to be no option to change it to FixedUpdate, so we ended up "fixing" it by changing the FixedUpate() method of Academy.cs to Update(). Training is slower, and there is still a frame of lag, but at least the models are learning again.
Hope it helps!
Alfredo
thanks for filing. we've logged this bug and will report back once we have a resolution.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.