Scripting the mesh morpher

I’m having trouble accessing an object’s mesh morpher via scripting. The code I’m using is:

void OnTriggerEnter ( Collider col )
{
	MeshMorpher mm = (MeshMorpher)col.gameObject.GetComponent("MeshMorpher");
	if (mm)
	{
		mm.enabled = true;
	}
}

And the error I get is: The type or namespace name “MeshMorpher” could not be found. Are you missing a using directive or an assembly reference?

Has anyone been successful when trying to do this?

Did you ever figure this out? Because I can’t seem to do it either.

–Eric

As I remember, you can’t script it.

Oh…but the docs say “You can modify the Frame directly to control the speed of the morph.” That implies it’s scriptable (and, in fact, quite useless otherwise). Seems to me that pretty much any value that can be changed in the inspector can also be changed with scripting, but I just can’t figure out how to access the mesh morph. If it’s not scriptable, why is it there? :wink:

–Eric

That’s my fault actually. I wrote that page of the documentation with the assumption that it was scriptable. When I attempted to try it for myself, I discovered that it was not. Please disregard that line, and I will remove it from the upcoming release’s documentation.

Sorry for any inconvenience!

EDIT: now that there is a mesh interface, you should be able to do animations using it. Try making your keyframes as separate meshes, and lerping between them using the mesh interface.

If you examine UnityEngine.dll, you’ll notice that there’s no MeshMorpher class at all. Although the component exists from the point of view of the GUI, there’s no way of accessing it from code.

Which seems like an odd omission…

What you can do though is make animation clips with the meshmorpher.

OK, that works and is easy enough, thanks! (Though it would have been a little easier just to use meshmorpher.frame = .6 or whatever. :wink: )

Is that more efficient than lerping meshes, and how is it done?

–Eric