Search Unity

is not a member of object problem

Discussion in 'Scripting' started by ebraheeemz, Sep 30, 2014.

  1. ebraheeemz

    ebraheeemz

    Joined:
    Sep 19, 2014
    Posts:
    7
    hi
    i have tow script files one i assign it to the player
    and the other i assign it to player->playersub->(assigned for this)playerchild

    this is the script code for player
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. public var currentValue = 0;
    and this the code for playerchild
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. public var faceValue : int = 0 ;
    4.  
    5. var dieGameObject: GameObject;
    6. var dieValueComponent ;
    7. function OnTriggerEnter( other : Collider ) {
    8.  
    9. dieGameObject = GameObject.Find("SixSidedDie");
    10.  
    11. dieValueComponent = dieGameObject.GetComponent(DieValue);
    12.  
    13.  
    14. dieValueComponent.currentValue = faceValue;
    15.  
    16. Debug.Log(faceValue);
    17.  
    18. }
    i have this error
    BCE0019:'currentvalue' is not a member of 'Object'.
     
  2. Cpt Chuckles

    Cpt Chuckles

    Joined:
    Dec 31, 2012
    Posts:
    86
    you didn't declare a type for currentValue, try this
    Code (csharp):
    1. #pragma strict
    2.  
    3. public var currentValue : int = 0;
     
  3. ebraheeemz

    ebraheeemz

    Joined:
    Sep 19, 2014
    Posts:
    7
    thanks, i tried that but still not work
     
  4. Cpt Chuckles

    Cpt Chuckles

    Joined:
    Dec 31, 2012
    Posts:
    86
    did you paste the entire content of the error message or is there anything more in it? if there is, paste the entire thing here
     
    ebraheeemz likes this.
  5. ebraheeemz

    ebraheeemz

    Joined:
    Sep 19, 2014
    Posts:
    7
    this a screen shot
    untitled.PNG
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You didn't define the type, so it's just Object.

    The type was declared. As long as you supply a value, the type is inferred. "var currentValue = 0" is fine and declares currentValue as an int.

    --Eric
     
    ebraheeemz likes this.
  7. ebraheeemz

    ebraheeemz

    Joined:
    Sep 19, 2014
    Posts:
    7
    thank you very much, the problem solved, i just need to mention the type of dieValueComponent
    so i declare it like this
    Code (JavaScript):
    1. var dieValueComponent = dieGameObject.GetComponent(DieValue);