Update SkinnedMeshRenderer with code

…whatever…delete this damn post, since for 2 days i get no advice on how to better approach this, and just get criticism from people who see the errors…

It will be much more performant if you do it on GPU / in Compute Shader, although it’s a lot more complicated if you are not familiar with it yet. But the “new” mesh API allows for this, there should be examples on the forums somewhere.

1 Like

Ohhhuuu. I would not call that a solution. What you actually do here is create a new mesh based on the current animation pose, you bake the mesh in that deformed pose, you do your mesh manipulations and then you essentially “reskin” that new mesh in that weird intermediate pose. So your original model is no longer in the T pose but whatever pose the animator was in at that moment. Doing this repeatedly can accumulaate all sorts of errors. Especially since skeletal animations can heavily distort your original mesh.

So all your animations would now be based on the intermediate pose as base pose. Ideally a system like this should apply the deformation to the original T pose mesh. Of course it’s difficult to map the deformations backwards as they would need to be “unskinned” so they can be mapped to the original T post. Your system does work, but since you transform from a transformed mesh to a new transformed mesh, doing this repeatedly could over time deteriorate the mesh.

I’ve seen real-time demage systems which essentially just store impact positions and radius information and dynamically apply the deformation in a shader. Though transforming those hit position back to the local space of the original mesh should probably work with your current approach as well.