So I’ve been at this for the pas t 6 hours… should be a fairly simple thing.
spawns around 160ish fighters when it should only spawn 3.
this script SHOULD work however unity is ignoring these rules completely:
if (CurrentFighters == FighterCapacity) {
SpawnFighters = false;
}
if (CurrentBomber == BomberCapacity) {
SpawnBombers = false;
}
overtime I launch a fighter I’m setting the count to +1 however I get way more then the Max level of fighters…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarrierBay : Photon.MonoBehaviour {
public float FighterCapacity = 3;
public float BomberCapacity = 2;
public float CurrentFighters = 0;
public float CurrentBomber = 0;
public bool IsOurs;
public bool SpawnFighters;
public bool SpawnBombers;
public CarrierAI CarrierScript;
public GameObject CarrierGameObject;
//----------------------------------------------------------------------------------------------------------------
void Start () {
CarrierScript = CarrierGameObject.GetComponent<CarrierAI> ();
SpawnFighters = true;
}
//----------------------------------------------------------------------------------------------------------------
// Update is called once per frame
void Update () {
if (CurrentFighters == FighterCapacity) {
SpawnFighters = false;
}
if (CurrentBomber == BomberCapacity) {
SpawnBombers = false;
}
//----------------------------------------------------------------------------------------------------------------
if (PhotonNetwork.isMasterClient == true) {
//----------------------------------------------------------------------------------------------------------------
if (SpawnFighters == true && IsOurs == true) {
CurrentFighters += 1;
PhotonNetwork.Instantiate ("T1Fighter", this.transform.position, this.transform.rotation, 0);
}
if (SpawnBombers == true && IsOurs == true && CarrierScript.distance < 1200) {
CurrentFighters += 1;
PhotonNetwork.Instantiate ("T1bomber", this.transform.position, this.transform.rotation, 0);
}
if (SpawnFighters == true && IsOurs == false) {
CurrentFighters += 1;
PhotonNetwork.Instantiate ("T2Fighter", this.transform.position, this.transform.rotation, 0);
}
if (SpawnBombers == true && IsOurs == false && CarrierScript.distance < 1200) {
CurrentBomber += 1;
PhotonNetwork.Instantiate ("T2bomber", this.transform.position, this.transform.rotation, 0);
}
}
}
//----------------------------------------------------------------------------------------------------------------
}