- Home /
 
 
               Question by 
               abz08 · Jul 23, 2014 at 04:47 PM · 
                gameobjectinstantiatetransform  
              
 
              How to insert my gameobjects in matrix form?
Hi!! I'm a beginner in unity. I want to know how to insert my gameobjects randomely in positions of a 3*3 matrix form. Please help me. Also guide me about the topics that I have to study if you could. Thanks in advance. :)
               Comment
              
 
               
              Answer by Onixus74 · Jun 25, 2015 at 12:48 PM
This should Create a 3x3 Objects then you have to spawn randomely in the position of cubes
 for (int i = 0; i < 3; i++)
         {
             for (int j = 0; j < 3; j++)
             {
                 GameObject tmpGb = Instantiate(Resources.Load("Cube", typeof(GameObject))) as GameObject;
                 tmpGb.transform.position = new Vector3(j * 1.5f-3 , i * -1.5f+3, 0);
                
             }
         }
 
              Your answer