i have a this simple object spawner
[Header("Pickups to Spawn")]
[Header("WEAPONS")]
[Header("Electricity Gun")]
public Transform[] SpawnPoints1;
public GameObject ElectricityGun;
public Text CurrentAmmoText;
public int currentAmmo;
public int maxAmmo;
public int pickupAmmo;
[Header("Missle")]
public Transform[] SpawnPoints2;
public GameObject Missle;
public Text CurrentMissleAmmoText;
public int currentMissleAmmo;
public int maxMissleAmmo;
public int MisslepickupAmmo;
[Header("ITEMS")]
[Header("Health")]
public Transform[] SpawnPoints2;
public GameObject HealthPickup;
public int HealthAmount = 10;
void spawn()
{
for (int i = 0; i < SpawnPoints1.Length; i++) {
Instantiate (ElectricityGun, SpawnPoints1[i].position, Quaternion.identity);
}
for (int i = 0; i < SpawnPoints2.Length; i++) {
Instantiate (Missle, SpawnPoints2[i].position, Quaternion.identity);
}
for (int i = 0; i < SpawnPoints2.Length; i++) {
Instantiate (HealthPickup, SpawnPoints2[i].position, Quaternion.identity);
}
}
void Awake () {
spawn ();
}
what this does is get a weapon pickup prefab and spawn it to its spawnpoints, but i quickly realized that if i keep going this could get real ugly and redundant script, so my question , is there a way to simplify/cleanup this?
maybe a way to click 1 button which would automatically add the variables for each item (such as current ammo, max ammo spawn to their spawnpoints etc) and i would only have to fill them up in the inspector?. also as i keep adding weapons, the inspector will get very busy with all the information about each item to be spawned etc so is there an cleaner method to do this? basically to not make a huge script of redundant stuff that maybe a method to do it more cleanly would do…
thanks!