How can I force a skinned mesh to update it's vertices from it's pose?

I need to render a skinned mesh to two different render textures in script. Both images should have the skinned mesh in different locations, orientations, and poses. Currently I am posing the mesh by sampling an animation, setting to the target texture to a pre-positioned camera and calling Render on this camera, then repeating with a second pose and a second target texture.

The result I get is a pair of images of the skinned mesh in the position that it was before my script was called.

My guess is that the bones are being correctly set by the SampleAnimation call, but that the skinning is not being recalculated because the rendering is happening in a script (an editor script at that). Is there a way to manually cause the skinning to be calculated on the skinned mesh? Or is there a way to have a scripted camera generate all the proper events so that the verts are skinned the normal way?

I appreciate that there are work-arounds possible (have two models, have multiple cameras in scene and let the game render them, etc) but the solution I’m looking for must work in a script I can trigger from a menu, and it must not be in a coroutine or involve other delays such as setting state and waiting for the next game frame.



With the help of Michael Nicolella I got this working and here’s how.

  1. Instead of rendering the one game object into two views I cloned the game object and all it’s children using GameObject.Instantiate().
  2. I iterated through each renderer in the new GameObject’s heirarchy and set the GameObject containing it’s layer to a special purpose layer so the camera rendering the render textures would not pick up both the clone and the original
  3. I pose the clone and call render on the camera.
  4. I DestroyImmediate() the clone game object.
  5. I repeat the above for the second view.

This actually fixed another issue, in that rendering a single game object in two poses moved it to the second pose and lost the pose it was originally in. Now that the posing is done in a clone the original object’s pose is left intact.

Thanks All