o, SO i set up this simple enemy spawner and when you kill one it spawns another awesome, however I end up with 20 Medium enemies rather then a maximum of 5…
any Idea’s on why its going over the limit?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnEnemy : Photon.MonoBehaviour {
public float maximumEnemy = 20;
public float maximumEnemyMedium = 5;
private GameObject SpawnLocation;
public GameObject[] Enemies;
public int index;
public GameObject[] Enemies2;
public int index2;
// Use this for initialization
void Start () {
SpawnLocation = this.gameObject;
}
// Update is called once per frame
void Update () {
if (PhotonNetwork.isMasterClient == true) {
Enemies = GameObject.FindGameObjectsWithTag ("EnemySmall");
index = Enemies.Length;
Enemies2 = GameObject.FindGameObjectsWithTag ("EnemyMedium");
index2 = Enemies2.Length;
if (index > maximumEnemy)
return;
GameObject Clone = PhotonNetwork.Instantiate ("Enemy", SpawnLocation.transform.position, SpawnLocation.transform.rotation, 0);
if (index2 > maximumEnemyMedium)
return;
GameObject Clone2 = PhotonNetwork.Instantiate ("EnemyMedium", SpawnLocation.transform.position, SpawnLocation.transform.rotation, 0);
}
}
//-----------------------------------------------------------------------------------------------------------
}