Hello all, Ive been at this for the last day or so, and its starting to bug me - I have no problem instantiating several random game objects out of an array of multiple game objects, I can grasp the random.range with no problem, but when it comes to making sure the same game objects aren’t instantiated more that once, I’m having difficulty, Ive tried a few scripts across the net but am having trouble… Could anybody give me a hand?
Heres my code:
var bodyParts : GameObject;
function GenerateBodyParts() {
var bodyPartsNum : int = Random.Range(0, bodyParts.length);
for (var i = 0; i < 3; i++) {
Instantiate(bodyParts[bodyPartsNum], transform.position + Vector3(0.05,0.05,-0.9), Quaternion.identity);
}
}
I’d really appreciate some help guys, in JS if possible as I’m not very competent in any other language at the moment.
I know there are scripts out there but i can’t seem to get them to work for this function, i.e. multiple random instantiations.
Cheers - monster.