Skip to content

Commit

Permalink
Prevented multiple GameController objects being instantiated.
Browse files Browse the repository at this point in the history
  • Loading branch information
bedder committed Nov 28, 2014
1 parent 1d55ad1 commit a16d526
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Assets/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ public class GameController : MonoBehaviour {
public GameObject playerController;

void Start () {
GameController[] controllers = GameObject.FindObjectsOfType<GameController>();
if (controllers.Length > 1)
Destroy(gameObject);
DontDestroyOnLoad(gameObject); // Keep between levels
nextLevel = 1;
}
Expand Down

0 comments on commit a16d526

Please sign in to comment.