Is it possible to swap meshes in / out at run time? Say for damage models, or even just completely replacing one w/ another?
Easily, in fact. The MeshFilter component takes a Mesh. So you can just swap this at runtime to whatever you want by a script. The same should be true for MeshCollider.
http://unity3d.com/Documentation/ScriptReference/MeshFilter.html
For example (untested):
var damagedMesh : Mesh;
function OnCollisionEnter()
{
(gameObject.GetComponent(MeshFilter)).mesh = damagedMesh;
}
That will set the mesh to what you assign to damagedMesh when the collider hits something. You can make it more advanced from there say by only switching the mesh when the collision velocity is above a certain value.
Hope that helps,
-Jon
awesome, I’ll have to play w/ that! Thank you!
Or you might want to instantiate an object and destroy the current one. The object you instantiate could have a particle system (or any other effects on it).
d.
1 Like