Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development

Angus Eliott
Angus Eliott
3,793 Points

C# Scripting malfunction

I asked this question around two days ago and didn't get an answer Here are the errors:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   62  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   62  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   62  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   65  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   68  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   68  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   68  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   68  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   68  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   71  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   71  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   71  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   71  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   71  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   74  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   74  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   74  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   74  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   74  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   79  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   79  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   79  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   82  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   83  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   83  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   83  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   83  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   86  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   86  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   86  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   86  Active
Error   CS1014  A get or set accessor expected  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   86  Active
Error   CS0548  'GameState.StartGame': property or indexer must have at least one accessor  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   60  Active
Error   CS0547  'GameState.StartGame': property or indexer cannot have void type    Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   60  Active
Error   CS0548  'GameState.EndGame': property or indexer must have at least one accessor    Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   77  Active
Error   CS0547  'GameState.EndGame': property or indexer cannot have void type  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   77  Active
Error   CS1955  Non-invocable member 'GameState.StartGame' cannot be used like a method.    Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   39  Active
Error   CS1955  Non-invocable member 'GameState.EndGame' cannot be used like a method.  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   45  Active
Warning CS0618  'Application.LoadLevel(int)' is obsolete: 'Use SceneManager.LoadScene'  Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   55  Active
Warning CS0618  'Application.loadedLevel' is obsolete: 'Use SceneManager to determine what scenes have been loaded' Frogs and Logs.CSharp   C:\Users\Angus\Documents\Unity\Frogs and Logs\Assets\Scripts\GameState.cs   55  Active

my code:

using UnityEngine;
using UnityEngine.UI;

public class GameState : MonoBehaviour {
    private bool gameStarted = false;
    [SerializeField]
    private Text gameStateText;

    [SerializeField]
    private GameObject player;
    [SerializeField]
    private BirdMovement birdMovment;
    [SerializeField]
    private FollowCamera followCamera;
    private float restartDelay = 3;
    private float restartTimer;
    private PlayerMovement playerMovment;
    private PlayerHealth playerHealth;
    private PlayerMovement playerMovement;

    // Use this for initialization
    void Start () {
        Cursor.visible = false;
        playerMovement = player.GetComponent<PlayerMovement>();
        playerHealth = player.GetComponent<PlayerHealth>();
        // Prevent the player from moving at the start of the game
        playerMovment.enabled = false;
        // Prevent the bird from moving at the start of the game
        birdMovment.enabled = false;
        // Prevent the Camera from moving to its game position
        followCamera.enabled = false;
    }

    // Update is called once per frame
    void Update () {
        // If the Game has not started And the player has pressed the space bar...
        if (gameStarted == false && Input.GetKeyUp (KeyCode.Space))
        {
            StartGame();
        }
        // if the player is not alive...
        if (playerHealth.alive == false)
        {
            // end the game...
            EndGame();

            // incrament a timer to count up to restarting...
            restartTimer = restartTimer + Time.deltaTime;


            // and if it reaches the restart Delay...
            if (restartTimer >= restartDelay)
            {
                // reload the currently loaded level
                Application.LoadLevel (Application.loadedLevel);
            }
        }

    }
    private void StartGame
    {
        GameStarted = true();
        // Remove Start Text...

        gameStateText.color = Color.clear;

        // Allow the player to move...
        playerMovement.enabled = true;

        // Allow the bird to move...
        bridMovement.enabled = true;

        // allow the camera to move...
        followCamera.enabled = true;

    }
    private void EndGame
    {
        GameStarted = false;

        // Show the Gameover Text...
        gameStateText.enabled = Color.white;
        gameStateText.enabled = "Game over!"

        // Remove the player from the scene...
        player.SetActive (false);

    }
}

Using MVS (Microsoft Visual Studio)

1 Answer

Geovanie Alvarez
Geovanie Alvarez
21,500 Points

In the StartGame method you got the GameStarted = true(); with parenthesis on the true remove the parenthesis to see what happen.