Hi, so basically I have a game over panel, with an animation attach to it to make the panel slide down when the player loses all of his lives. I created a UI script to help me pause and unpause game objects behind the The game over panel when it comes down. It works but I have enemies that spawns randomly in my game, so the clones aren’t being paused when the gamover panel comes down. Does anybody know how to stop cloning object when the game over panel is paused.
This is my spawning script: (Javascript)
#pragma strict
// Variable to store the enemy prefab
public var enemy : GameObject;
public var gameCharacters : GameObject;
// Variable to know how fast we should create new enemies
public var spawnTime : float = 2;
function Start() {
// Call the 'addEnemy' function every 'spawnTime' seconds
InvokeRepeating("addEnemy", spawnTime, spawnTime);
}
// New function to spawn an enemy
function addEnemy() {
// Variables to store the X position of the spawn object
// See image below
var x1 = transform.position.x - GetComponent.<Renderer>().bounds.size.x/2;
var x2 = transform.position.x + GetComponent.<Renderer>().bounds.size.x/2;
// Randomly pick a point within the spawn object
var spawnPoint = new Vector2(Random.Range(x1, x2), transform.position.y);
// Create an enemy at the 'spawnPoint' position
Instantiate(enemy, spawnPoint, Quaternion.identity);
}
And this is how I pause my game (within my UI script):
public class UIManagerScript : MonoBehaviour {
public GameObject gameCharacters;
public void PauseGame()
{
if (gameCharacters != null)
{
gameCharacters.SetActive(false);
}
}
public void UnPauseGame()
{
if (gameCharacters != null)
{
gameCharacters.SetActive(true);
}
}
}