Turning a mesh into a different mesh

Let me start off by saying I am and artist not a scripter, so I what I ask makes no sense please go easy on me!

Anyway Im working on a project that has multiple destroyable structures, right now I have a script that will change the textures based on damage they take. What I need to do is allow myself and other artist the ability to change the mesh and texture of the object.

I’m not sure how to tell the script to swap the starting mesh out for the damaged versions.

What I have setup up right now is

var undamaged : Mesh;
var damaged : Mesh;

Should the undamged be Gameobject instead of Mesh sine it’s the original object in the scene? Also I am using the Mesh variable so that it is easy to quicky create the destructible objects for the artist.

Thanks for any help you can provide!

Import the two models and make 2 seperate game objects with them.

Then create an empty Game object and add the two models to it as children.

Set the renderer in the damaged building off, that check box. Or set the whole object off at the top. (I think the collider still works even when the renderer is off.)

So now you only see one object.

Write a script that turns the objects on and off based on your game rules. Put that script into the parent object. To get a reference to each object you’ll need to drag them to some public variables you write in the script, in the Inspector.

Thanks for the reply Tzan!

I began attempting to use your suggestion but I’ve run into an issue, I cannot figure what the command is to turn a child on and off in Unity Script.

My other concern is how exactly will the children be referenced in the script, the reason I want to use the

var undamaged = GameObject;
var damaged = GameObject;

was so that it would be very simple for myself and other artist to get our destroyed assets in game, if the script needs to be modified for every different type of building it seems a bit counter-productive.

I apologize if this is painfully simple stuff, my focus is art and am trying to understand some applied scripting.

Look at “active”

Those var can be used. Like I said before, you will still need to drag the building/prefabs/gameojects onto those public variables in the Inspector panel.

Assembling the game in the editor involves using the editor, you need to do some tutorials. The dragging concept is very common.

I actually found the “Active” right after I posted last night!

So yeah, I know how to add children to a Game Object, my question is how do I call them out in the script.

My issue may be that I just don’t know the proper name of things in Unity,

Thanks again for your help, like I said I’m an artist so I am very new to scripting. If you know any good tutorials that cover this sort of scripting I would love to see them, digging through the Unity scripting reference raises more questions for me than it answers. :stuck_out_tongue:

You can search by tag GameObject.FindWithTag(“name of tag”) or one of the other tag functions or by name with (I believe) GameObject.Find(“name of gameobject to find”).

You really need to go over the reference guides and other documentation/tutorials. It won’t take long to get up to speed, less time then waiting for answers in the forum.

A tutorial that involves changing one object for another is the First Person Shooter tutorial. It shows an example with both a character and barrels.

If the object isn’t too complex, can’t you just store the position and rotation, delete the old object, and put the new object in with the coordinates?

Dont forget about UnityAnswers.

Tutorial list

http://answers.unity3d.com/questions/4897/how-can-i-start-learning-unity-fast-list-of-tutorials

Did I just blow your mind?
I didnt know it was there either till just now :slight_smile: