Search Unity

game with databese SELECT give me the same element

Discussion in 'Scripting' started by Xalion, May 25, 2017.

  1. Xalion

    Xalion

    Joined:
    Jun 4, 2014
    Posts:
    21
    hi im doing a game with a database i make the connection working , i setup the DB connect, query, disconnect function (see img 1) everything is okey. i setted the game that if the object collide it calls a query(see img 2) anyone ave idea why it call me the same elment, so why the variable int numero not increses ??
    thanks
     

    Attached Files:

    • img1.png
      img1.png
      File size:
      187.3 KB
      Views:
      739
    • img2.png
      img2.png
      File size:
      179.9 KB
      Views:
      705
  2. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Each "laserBlue" has its own copy of "numero". So every time you make a new laser, it has the default value of zero. It would only go up if the same laser hit multiple things. If you want all the lasers to share the same "numero", the easiest way to do it is make it static:
    Code (csharp):
    1. public static int numero = 0;
     
  3. Xalion

    Xalion

    Joined:
    Jun 4, 2014
    Posts:
    21
    thanks ... now it works and ifell so dumb :)
     
    makeshiftwings likes this.