Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public GameObject pre;
- public int counter = 0;
- public int worldWidth = 20;
- public int worldHeight = 20;
- private float positionX;
- private float positionY;
- void Start()
- {
- chessBoardCube = Resources.Load<GameObject>("Prefabs/pre");
- positionX = -11.24f;
- positionY = 4.8f;
- counter = 0;
- }
- void Update()
- {
- for (int x = 0; x < worldWidth; x++)
- {
- for (int z = 0; z < worldHeight; z++)
- {
- if (counter % 2 == 0)
- {
- GameObject block = Instantiate(pre, Vector3.zero, Quaternion.identity) as GameObject;
- block.renderer.material.color = Color.black;
- block.transform.parent = transform;
- float xP = positionX * 3;
- float yP = positionY * z;
- block.transform.localScale = new Vector3(2, 2, 1);
- block.transform.localPosition = new Vector3(xP, 0);
- }
- else
- {
- GameObject block = Instantiate(pre, Vector3.zero, Quaternion.identity) as GameObject;
- block.renderer.material.color = Color.red;
- block.transform.parent = transform;
- float xP = positionX * x;
- float yP = positionY * z;
- block.transform.localScale = new Vector3(2, 2, 1);
- block.transform.localPosition = new Vector3(xP, 0);
- }
- }
- counter++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement