Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4.  
  5. public class randomgen : MonoBehaviour {
  6.  
  7.  
  8. public GameObject[] prefs = new GameObject[3];
  9.  
  10. public int gridX = 5;
  11. private float y = 0;
  12. public float spacing = 2f;
  13.  
  14.  
  15. // Use this for initialization
  16. void Start () {
  17.  
  18.  
  19. for (int x = 0; x < gridX; x++) {
  20.  
  21. Vector3 pos = new Vector3(x * spacing + 0, 3, y);
  22.  
  23.  
  24.  
  25. int rndId = Random.Range(0, prefs.Length);
  26.  
  27.  
  28.  
  29.  
  30.  
  31. Instantiate(prefs[rndId], pos, Quaternion.identity);
  32.  
  33. GameObject temp = prefs [rndId];
  34. prefs [rndId] = prefs [prefs.Length - 1];
  35. prefs [prefs.Length - 1] = temp;
  36.  
  37.  
  38.  
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement