x


rpg inventory

I want to create an inventory system that keeps track of the amount of each item you have and are able to scroll through each one and selecting which ever item will activate it. I'm unsure what exactly to use to accomplish this. Should I use an array of items that keeps track of the item name and how many of each you have? Also I don't know how to make it so when you scroll through that the system can keep track of which item you are on by displaying an arrow next to it and then tell if it has been selected. Once selected I am also unsure of how to activate a certain function from that array. So here's an example of how it would look ingame.

Inventory 

> potion1 [ 1 ]
  potion2 [ 0 ]
  potion3 [ 5 ]
more ▼

asked Apr 02 '12 at 07:04 AM

jessee03 gravatar image

jessee03
300 58 80 90

Have you ever done a programming course? This looks suspiciously like the kind of thing they get you do to in those... Of course, doing it in the 'print x chars then print name' method isn't really appropriate for Unity.

Apr 02 '12 at 07:08 AM syclamoth

I have but I am not very good or haven't done a lot of programming using arrays and such... What I'm trying to do is a little complex. Being able to scroll through and select each item and if there's atleast one then your able to use it.

Apr 02 '12 at 07:18 AM jessee03

Well, if you want to make games, get good at programming. There's really no way around it- it won't be possible for you to do a lot of things without knowing how to break down a task into algorithms, and how to tell a computer how to implement those algorithms.

Apr 02 '12 at 07:48 AM syclamoth

I couldn't agree more with syclamoth. Although this particular task isn't extremely hard to overcome, your main friend here is for-loops and arrays (to start with). It also depends on which platform this is intended for.

Apr 02 '12 at 08:50 AM save
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The structure of your program will be a little more complex than using an array. You will best use some object oriented concepts. Read them up if you do not know about them.

The way I would design the inventory system: Have an inventory class with a list of inventory items. Inventory items are again a class which consists of a pointer to an inventory object (your potions in this case) and a counter.

You will also need to implement some kind of GUI in the inventory class with a cursor through which you can activate your inventory item and decrement the counter.

more ▼

answered Apr 02 '12 at 07:39 AM

senad gravatar image

senad
641 3 5

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x234

asked: Apr 02 '12 at 07:04 AM

Seen: 732 times

Last Updated: Apr 02 '12 at 08:50 AM