Hello, how can i turn off this by using a bool to stop spawning and then make it spawn when the bool is true? i am getting no error’s but it is not working? here is my code. This is C#
using UnityEngine;
using System.Collections;
public class cointopon : MonoBehaviour
{
public Transform[] spawnPoints;
public GameObject[] enemyPrefabs;
public float amountEnemies = 20; // Total number of enemies to spawn.
public float yieldTimeMin = 0;
public float yieldTimeMax = 5; // Don't exceed this amount of time between spawning enemies randomly.
public int i;
public bool state;
void Update (){
yieldTimeMin = PlayMakerGlobals.Instance.Variables.GetFsmFloat("coinboolmin").Value;
yieldTimeMax = PlayMakerGlobals.Instance.Variables.GetFsmFloat("coinboolmax").Value;
amountEnemies = PlayMakerGlobals.Instance.Variables.GetFsmFloat("coinboolamount").Value;
state = PlayMakerGlobals.Instance.Variables.GetFsmBool("coinbool").Value;
if (state == true){
Spawnblocks();
}
else if (state == false) {
Debug.Log ("false");
}
}
public IEnumerator Spawnblocks() {
for (i=0; i<amountEnemies; i++){
var randNum = Random.Range(0, spawnPoints.Length);
yield return new WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax)); // How long to wait before another enemy is instantiated.
var obj = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)]; // Randomize the different enemies to instantiate.
var pos = spawnPoints[randNum];
Instantiate(obj, pos.position, pos.rotation);
}}}