This Script comes up with an error and I’m not certain what it wants me to do.
the script
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class gameOver : MonoBehaviour {
private GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
private int numPlayers = players.Length;
public Text gameOverText;
void Update()
{
if (numPlayers < 1)
{
gameOverText.Text = "GAME OVER";
}
}
}
and the error
Assets/gameOver.cs(8,34): error CS0236: A field initializer cannot reference the nonstatic field, method, or property `gameOver.players'
I’ve tried using both public and private variables but neither worked whats going wrong?