Hi,maybe someone can help me. I want to use my int variable in another script, but I get this error. How can I solve this problem?
public class GameSettings : MonoBehaviour {
public int gameMode;
void OnGUI()
{
if (GUI.Button (new Rect (Screen.width/100 * 50 -(Screen.width/100 * 25 /2), Screen.height/100*25, Screen.width/100 * 25, Screen.height/100 * 20), "Easy", customButton))
{
gameMode = 1;
Application.LoadLevel("Scene");
}
if (GUI.Button (new Rect (Screen.width/100 * 50 -(Screen.width/100 * 25 /2), Screen.height/100*50, Screen.width/100 * 25, Screen.height/100 * 20), "Normal", customButton))
{
gameMode = 2;
Application.LoadLevel("Scene");
}
if (GUI.Button (new Rect (Screen.width/100 * 50 -(Screen.width/100 * 25 /2), Screen.height/100*75, Screen.width/100 * 25, Screen.height/100 * 20), "Hard", customButton))
{
gameMode = 3;
Application.LoadLevel("Scene");
}
}
public class BirdMovement : MonoBehaviour
{
float Speed = 100f;
public int newGameMode;
void Start ()
{
GameSettings targetScript = newGameMode.GetComponent<GameSettings>();
switch(newGameMode)
{
case 1:
{
float Speed = 100f;
Debug.Log(flapSpeed);
break;
}
case 2:
{
float Speed = 120f;
Debug.Log(flapSpeed);
break;
}
case 3:
{
float Speed = 140f;
Debug.Log(flapSpeed);
break;
}
default:
{
float Speed = 160f;
Debug.Log("default");
break;
}
}
}