HOW to bind SCRIPT to an OBJECT on the stage SOFTWARE?
Quite recently I started learning Unity. Everything went quite smoothly and well, until it happened. I decided to do this: (the analogy is given so that it would be easier to understand):
1) Create a cube
2) I make a clone of this cube at the click of a button
3) Specify another script for this clone (when a clone is created, the script is not duplicated)
Screwed up at the 3rd step ¯_ (ツ) _ / ¯
1) The cube is already on stage 2) I duplicate it with Instantiate(myCube); 3) The cube from which copies are created simply moves around the stage (WASD), and the cubes that are duplicated change color / move erratically / increase 4) For each created cube, the action that it will perform is set randomly
GameObject cube; ... void createCloneCube(){ GameObject clone; clone = Instantitate(cube) as GameObject; clone.GetComponent<BoxCollider>().enabled = true; //Тут должен быть скрипт добавления компонета Script к clone } 