Search Unity

this.name possibly an issue?

Discussion in 'Scripting' started by 2dgamemania, Oct 30, 2014.

  1. 2dgamemania

    2dgamemania

    Joined:
    Apr 30, 2014
    Posts:
    153
    Hi, I'm having a hard time understanding where certain variables are stored./ accessed

    I have created a public variable at the top of my main script
    Code (csharp):
    1.  
    2. public var cardmatches=new Array();
    3.  
    I can edit and change this within the update function and works fine

    my problem is if I try and make changes within the mousedown() function where i have the following code
    Code (csharp):
    1.  
    2. if (this.tag=="card1")
    3.    {
    4.        cardmatches[1]=1;
    5.  
    6.    }
    7.  
    8.  
    If I run the following from within the update() function it returns nothing, doesnt show cardmatches with the value of 1.

    Code (csharp):
    1.  
    2. Debug.Log("cardmatches within this tag = "+cardmatches[1]);
    3.  
    I presume its something to do with it storing it within an instance and thats why the variable isnt updating but dont quite understand how i can proceed..

    Any help with this would be appreciated, thanks
     
    Last edited: Oct 30, 2014