Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Unity v1.2.2 tutorial, page 17

Discussion in 'Editor & General Support' started by Pavlov, Jun 6, 2006.

  1. Pavlov

    Pavlov

    Joined:
    Jun 7, 2005
    Posts:
    41
    I've created the 'Enemy script.js' as shown below and attached it to both of the enemies.

    var score : Score;

    function Update () {

    if (transform.position.y < -2) {

    Destroy (gameObject);
    score.AddToScore ();
    }
    }

    I've created the 'score.js' script as shown below and attached it to the GUIText object Score (which is actually a text object shown in the GameObject menu).

    var score = 0;

    function AddToScore () {

    ++score;
    guiText.text = "Score: " + score.ToString ();
    }

    It keeps complaining about 'Assets/Working Assets/Scripts/enemy script.js(1) error BCE0018: The name 'Score' does not denote a valid type.' Stupid question, what am I missing?
     
  2. Pavlov

    Pavlov

    Joined:
    Jun 7, 2005
    Posts:
    41
    got some help from the irc, the name of the script file wasn't uppercased. I need to follow Unities coding standard.