Last active
January 28, 2022 21:48
-
-
Save ismailbayram/62d13c1f89f3f1dae4dbcaaa4df88b95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class GenerateTanks : MonoBehaviour | |
{ | |
public GameObject[] bodies; | |
public GameObject[] towers; | |
public GameObject[] cannons; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
GameObject emptyTank = new GameObject(); | |
int i = 0; | |
int j = 0; | |
int k = 0; | |
foreach (GameObject bodyObject in bodies) | |
{ | |
j = 0; | |
foreach (GameObject towerObject in towers) | |
{ | |
k = 0; | |
foreach (GameObject cannonObject in cannons) | |
{ | |
GameObject tank = Instantiate(emptyTank, new Vector3(i * 10f, 0f, (j + k) * 10f), Quaternion.identity); | |
tank.name = string.Format("Tank {0}-{1}-{2}", i + 1, j + 1, k + 1); | |
tank.transform.position = new Vector3(i * 10f, 0f, (j + k) * 10f); | |
GameObject body1 = Instantiate(bodies[i], Vector3.zero, Quaternion.Euler(-90, 0, 0), tank.transform); | |
GameObject tower1 = Instantiate(towers[j], new Vector3(0, 0f, 0), Quaternion.Euler(-90, 0, 0), tank.transform); | |
GameObject cannon1 = Instantiate(cannons[k], new Vector3(0, 0, 0.22f), Quaternion.Euler(-90, 0, 0), tank.transform); | |
k++; | |
} | |
j++; | |
} | |
i++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment