I am new to scripting and I find it very hard to grasp. I have a project for an internship for my game design skills but this also means I have to do some scripting to complete certain tasks. I have the grasp of most things I need but arrays and loops are not my friends. This is my problem. I instantiate six objects randomly from an array of game objects. This works fine but I frequently get the same object instantiated twice or more. I have searched all the questions in unity and Googled all sorts of word combinations but they all seem to involve integers and numbers printed out not actual game objects.I know I have to use a for loop but I’m not sure where to start. This is the section of code I need to add to I know but I’m not quite sure how.
function LeftChoices()
{
objArray = new GameObject[6];
for (var i : int = 0 ; i < 6 ; i++)
{
objArray _= Instantiate(leftObjArray[Random.Range(0,leftObjArray.Length)], posArray *, Quaternion.identity);*_
* }*
}
If someone could give me a hand that would be absolutely awesome. Many thanks in advance.