Using SkinnerMeshRenderer.BakeMesh() for Unity Cloth Objects

Hi,

My issues straddles a number of areas but thought this was the best place to post.

I have a Unity cloth object attached to my character, essentially a cord with a bobble on the end.

The only issue is that I have a ‘bobble’ at the end of the cloth cord, if it’s part of the cloth mesh then it looses all volume under gravity and looks like a deflated balloon rather than a ball (see example on the left in the video)

To maintain the volume of the ‘bobble’ I want to have it as a separate game object and attach it at run-time to a vertex on that cloth cord object, snapping it’s transform to the vertex position on each frame.

After reading up about it I thought the best way to attempt this was using the SkinnedMeshRender.BakeMesh function. The idea being that it would bake the cloth cord mesh off each frame so I can sample the vertex position and use it to position the separate ‘bobble’.

My script (which is attached to the dynamic cloth cord game object) is mostly working but the ‘bobble’ still looks like it is being positioned to the original vertex position (before the cloth deformation has occurred) rather than the dynamic cloth position (see the example on the right in the video)

https://vimeo.com/229256679

My questions is, does the SkinnedMeshRender.BakeMesh function work with Unity Cloth? If so, does anyone have any ideas on what I’m doing wrong. My script is attached below

Many Thanks in advance and apologies if it’s a rookie mistake,

Alex

Hi,

I’ve actually solved this myself. Instead of used SkinnedMeshRenderer.BakeMesh() to bake off the dynamic cloth mesh each frame I simply used cloth.vertices which just worked just fine allowing me to access the cloth vertex positions at run-time.

Cheers,
Alex

Thanks, it helped me.