So, I am trying to figure out the best way to add something to a game object via script.
I have imported a model and also copied it to an empty prefab and I am trying to figure out how to attach it to an empty gameobject through a script.
I have tried using the gameobject Find and then using AddComponent, but apparently that doesn’t accept objects lol. So, if anyone has a link that better explains to me how to do this, or the line of code that does it, it would be much appreciated.
This is what I last tried. Sloppy, but this is my “get to really know unity” project:
var head1 : GameObject;
head1 = GameObject.Find("head1");
head1.AddComponent(Resources.Load("bodyParts/head1"));
head1 is the empty gameobject attached to my model in the scene.