Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

BCE0005: Unknown identifier: 'Cubes'.

Discussion in 'Scripting' started by ahmedalheday, May 6, 2014.

  1. ahmedalheday

    ahmedalheday

    Joined:
    Feb 24, 2014
    Posts:
    103
    i am having a problem of tagging the cube to the script
    if it does not work i can loed the next level after all the cubes have been taken
     
  2. ahmedalheday

    ahmedalheday

    Joined:
    Feb 24, 2014
    Posts:
    103
    #pragma strict

    var levelend = false;
    var maxpoints : float = 12;

    function Update () {

    if (Cubes.score >= maxpoints) {

    Application.LoadLevel ("level2");

    }

    }

    heres the script
     
  3. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Nobody can help you until you explain what Cubes is.
     
  4. ahmedalheday

    ahmedalheday

    Joined:
    Feb 24, 2014
    Posts:
    103
    i justed posted it right there
     
  5. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    The script you posted shows how you are using Cubes but doesn't show what Cubes is, or what exactly is inside it.

    We need to see it in order to know if it is a struct or a class, if score is a static variable, etc.
     
  6. ahmedalheday

    ahmedalheday

    Joined:
    Feb 24, 2014
    Posts:
    103
    ohhh

    do u know the rolling ball project
    i am working on that so now all what i need is a script that takes me from one level to the other
    the cubes are the stuff that we peck up
     
  7. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,952
    No, you showed something referencing Cubes, not what it is. And clearly the script doesn't know what it is either. Hence "Unknown Identifier : Cubes" Your script doesn't know what it is so you can't use it. You need to either identify it, find it, link to it, or make it static before you can use it.
     
  8. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    No, and I doubt many forum members have the project installed and ready to reference so we'll need to you post the script that declares Cubes.
     
  9. ahmedalheday

    ahmedalheday

    Joined:
    Feb 24, 2014
    Posts:
    103
    using UnityEngine;
    using System.Collections;

    public class aroundwego : MonoBehaviour
    {

    // Update is called once per frame
    void Update ()
    {
    transform.Rotate(new Vector3(15, 30, 45)* Time.deltaTime);
    }
    }
     
  10. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Last edited: May 6, 2014
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    ahmedalheday:

    The error: BCE0005: Unknown identifier: 'Cubes'. is letting you know that you are using and indentifier that is unknown and that this identifier is called "Cubes".

    You are asking the computer to do something with this line:
    Code (csharp):
    1. if (Cubes.score >= maxpoints)
    You are asking the computer:
    If the score on the Cubes item is greater than maxpoints... then "do something", in this case, load a new level.

    But you have not told the computer what "Cubes" is.

    If you were in a Cafe, and someone came up to you and asked:

    "Hey, I would like a coffee and a samophlange, please."

    ... you would say:

    "What's a samophlange?"

    This person has used two identifiers: "Coffee" and "Samophlange". You know what coffee is. You don't know what a samophange is, so he must tell you.

    The computer doesn't know what "Cubes" means. You must tell the computer.

    We can't tell you what "Cubes" means. You must tell us.

    We can guess?

    It looks like it's the name of a GameObject that holds a property or value called "score"?

    If this is true you need to create a reference that is connected to the item "Cubes".

    If my guess is correct, at the top of the script you need to create a public reference to the Component Type or Script Name of Cubes that holds the score value.

    If you have a script called Cubes.js on a GameObject, you would need a line like:

    Code (csharp):
    1. public var cubes : Cubes;
    ... this is public (so it can be accessed), var (indicating this is a variable), cubes (with a lowercase c for the name), a colon (for syntax) and Cubes (with an uppercase c, matching the name of your script, which is the "Type"), followed by a semi-colon (ending the line).

    You need to drag a reference to the GameObject with the Cubes.js script on it into the public slot on the GameObject with the code in your post.

    There are other minor issues, but we can go into these later.

    If this doesn't make sense, then I'd suggest stepping back and watching more of the learning lessons, and reading the introduction sections of the manual again:
    http://unity3d.com/learn
     
  12. hadiai

    hadiai

    Joined:
    May 10, 2014
    Posts:
    9
    Agree, you need to add more detailed information if you want to get any real help