Hello,
I’ve run into a slight problem, well… here’s the problem.
I’m making a script to cut down trees,
Each tree has it’s own log count.
I want to Instantiate amount of objects = log count,
Any help would be greatly appreciated.
Thanks for reading!
var MaxLogs = 100; // Max logs of tree var Logs = 0; //this doesn't matter var Tree : GameObject;//type of tree function TreeDead () { // Instantiates 10 copies of prefab each 2 units apart from eachother
var prefab : Transform; for (var i : int = 0;i < 10; i++) { Instantiate (prefab, Vector3(i * 2.0, 0, 0),Quaternion.identity);
}
}
Instead of Instantiates 10 copies of prefab, i want it to Instantiates amount of logs, so if var Logs = 4; Instantiates 4 copies of prefab
We'll need more details on your specific problem. You'll probably need a better understanding of Unity and/or coding before our answers will help you very much.
– HuacanachaJust replace the '10' in the for loop with 'Logs'. As it stands it won't Instantiate any prefabs becuase Logs=0, so make sure you set Logs to whatever you want before the for loop is run.
– Huacanacha