Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Space Shooter tutorial game won't restart

$
0
0
I get the error below and then I'm pointed to this code. The problem started after switched the GameController code to use the "UnityEngine.SceneManagement" function. Now every time I press "R" to restart it turns off the Game Controller Cannot find 'GameController' script UnityEngine.Debug:Log(Object) DestroyByContact:Start() (at Assets/Scripts/DestroyByContact.cs:24) void Start () { GameObject gameControllerObject = GameObject.FindGameObjectWithTag ("GameController"); if (gameControllerObject != null) { gameController = gameControllerObject.GetComponent (); } if (gameController == null) { Debug.Log ("Cannot find 'GameController' script"); } } using System.Collections; using UnityEngine; using UnityEngine.SceneManagement; public class GameController : MonoBehaviour { public GameObject[] hazards; public Vector3 spawnValues; public int hazardCount; public float spawnWait; public float startWait; public float waveWait; public GUIText scoreText; public GUIText restartText; public GUIText gameOverText; private bool gameOver; private bool restart; private int score; void Start () { gameOver = false; restart = false; restartText.text = ""; gameOverText.text = ""; score = 0; UpdateScore (); StartCoroutine (SpawnWaves ()); } void Update () { if (restart) { if (Input.GetKeyDown (KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>