Changing Mesh during game

I can’t wrap my head around this one.
I’ve searched endlessly for a solution but I couldn’t find one.
Basically, what I need to do is change a mesh with another one in-game.
The problem is that the mesh (meshes) happens to be my my character’s arms.
Basically I want to be able to morph my character’s arms from one mesh to another at the press of a button.
How should I go about rigging the character and scripting the mesh exchange?

You can change the mesh with this code, I’m not entirely sure
whether it causes problems with rigged objects or not though.

MeshFilter filter = GetComponent<MeshFilter>();
filter.mesh = newMesh;

This instantly changes your mesh, it doesn’t blend in slowly.
I can’t think of a way to do this so what I’d do is model the transition of the mesh in frames.

Well, first of, both meshes need to share the same BoneWeights, in order for the SkinnedMeshRenderer to animate it properly. Tho, if its not animated at all it doesnt matter.

Furthermore, you now have to distinguesh cases. Are the modells split? If so you can simply use the above answer to exchange the mesh at runtime.

However, if its a submesh, you will have to mess with the modell geometry. If you are interested in something like this, you might want to have a look at my new tool, BatchMan. (See signature) ;o

1 Like