I am making a game and I urgently need to know how to make my game stop(including counter) when I die.
This is my enemy script.
using UnityEngine;
using System.Collections;
public class Cubes : MonoBehaviour {
public float delay = 0.1f;
public GameObject cube;
// Use this for initialization
void Start () {
InvokeRepeating("Spawn",delay,delay);
}
// Update is called once per frame
void Spawn () {
Instantiate(cube,new Vector3(Random.Range(-6,6),10,0),Quaternion.identity);
}
public bool readyToKill = false;
}
All help will be greatly appreciated! Thanks in advance!
If you mean by stopping the game like when you open a pause menu, then Time.timescale = 0 might be the solution for you. From there you can fade in a game over window on the canvas to let the user play again or whatever options are available.
I have the player as the game object and I have the script for the enemy that makes the enemy spawn. As the script of the cubes are not a game object and just a script, how do I make it that when the player hits the script (in a way) the player dies or spawns back? Thanks for any help!