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

best way to store various values

Discussion in 'Scripting' started by tawdry, Mar 14, 2015.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Hey guys
    So the scene is I have 5 allies and 10 enemies and I have to store all there distances from each other there respective health ,type of object,importance etc.
    So I just started using arrays but they don't seem right for this job.

    For instance i would need just for 1 ally a array for distx10 another for healthx10 etc.so for all 5 allies alone thats 5(allies)x4(arrays)(10)(items) arrays then the enemies do the same for them its 10x4(5) array lists.

    I'm looking for a way to store multiple values,strings etc in a single type array?As in 5(allies)x1(array)[4](values)(10)(items)
    What would be he easiest solution. I will need to be able to compare the results against each other. Any suggestions?And If you could provide a sample code I won't understand the terminology probably.
     
  2. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    I'm not quite sure if that's what you're asking for, but have you thought about writing your own class? Then you'll have your own type holding all neccessary information and you can create an array or a list etc. You'd also be able to define a method that compares two instances with each other or whatever logic you want to do.
     
  3. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    " I won't understand the terminology probably". I give noobs a bad name. Write my own class lol any link to how you write a class?
     
  4. SevenHams

    SevenHams

    Joined:
    Dec 27, 2012
    Posts:
    67
  5. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Well, you've already written some classes, as i saw in other threads. :p
     
  6. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Oh did I . Well color me impressed and I did it without even realizing just imagine my potential:)
     
  7. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    I will check them out Seven thx for the info.