- Home /
I need help on Classes and Arrays for inventory.
So i am trying to make an inventory system but i have no idea where to begin. Im not new at coding but iv never used classes and arrays before so i am not sure which one i should use for an inventory. Should i use classes or arrays? Thanks i am using javascript.
This question is far too general for unityAnswers. Better ask it on the forum. Also you should get some experience about classes and arrays in generall before going for something komplex. This is like asking "I want to drive in a motor race. How does the steering wheel work?". You can find many tutorials online. If this does not help you can also buy a book.
Where can i learn about class variables? Iv been looking but i cant find anything on them.
Answer by iwaldrop · Feb 10, 2013 at 06:28 AM
Lockstep makes a good point; keeping with his analogy, you should definitely learn how the steering works! :)
But what you need to realize is that an Array is just a collection of objects. Ints are objects, floats, GameObjects, Transforms, and Components are all objects. So are your own Classes. So what you need to figure out is what you want to keep a list of. You're probably going to need one, but whether you keep references to the GameObjects or some InventoryItem class that you create is something you're going to have to figure out.
Feel free to ask some more questions about that, in a new question, of course.
Where can i learn about class variables? Iv been looking but i cant find anything on them.