- Home /
 
Get number from a variable name
Hi everyone ! I've some difficult to find an answer to my problem..
Can someone explain me how to get a number from a variable and use in as an index with the "i" in a loop for ?
 //Coordoninates for the player 1
 x1 = P1.transform.position.x;
 z1 = P1.transform.position.z;
 function GetPosition()
 {
     //Check position form all players
     for(var i : int = 0; i<nCaseArray; i++)
     {
         xTotal = xTotal + (x+"i");
         zTotal = zTotal + (z+"i");
     }
 }
 
               Then i search the syntaxe for call the " 1 " in x1 with the i ( index ) of my for loop !
Thanks a lot !
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
How can i attach a bullet to a tower 2 Answers
Using Loops 1 Answer
Having Trouble with this For Loop 1 Answer
For loop going based off of Time.deltatime? 1 Answer
Adding an object to an array only if it is not in the array 2 Answers