ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

Mecanim IK delays with observations

Open asolano opened this issue 8 years ago • 5 comments

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:

side

And this is the expected result:

front

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:

eyesout

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

asolano avatar Mar 14 '18 09:03 asolano

I also have these problems.

r-lipton avatar Mar 23 '18 09:03 r-lipton

Any news @asolano ?

r-lipton avatar Mar 27 '18 14:03 r-lipton

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

asolano avatar Mar 30 '18 08:03 asolano

thanks for filing. we've logged this bug and will report back once we have a resolution.

shihzy avatar Apr 11 '18 22:04 shihzy

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.

lock[bot] avatar Apr 04 '20 08:04 lock[bot]