- Home /
The question is answered, right answer was accepted
Inventory System
Hello, I need a good inventory system with item Pick up, Drop items and "I" button to open Inventory window.. Can you please help me with that cuz i searched but nothing helped me... Thank you :)
@$$anonymous$$artinZahariev hey man, we would really appreciate it if you could choose an answer. Just hit the Checkmark to the left of the answer that solved your problem.
Hello, this tutorial might help you out: https://www.youtube.com/watch?v=$$anonymous$$LaGkc87dDQ
Answer by vexe · Oct 05, 2013 at 07:45 AM
This isn't a site where you request/order stuff and have others do it for you, this is a site where you ask for solutions to problems you are having during whatever it is that you're working with. Do you really expect someone to answer you with a full inventory system? ;-)
Generally speaking, an inventory system involves having a Bag
, with a sequence (a List
perhaps) of Slot
, where each Slot
(or Slots, if you wanted your items to take more than one slot) has an Item
- That's one way, Or if you wanted it to be gridless, you could immediately store the items inside the bag.
Anyway, here's a good inventory system from Brackeys (Free)
And here's a series that might help as well.
Sorry if I sounded mean, but users should know what kind of questions to ask, at least read the FAQ :)
TIP: Start small, and walk forward, it takes time. Use a good GUI system, like NGUI.
Seems like he was asking for help on an inventory system, not ordering one.
Answer by phxvyper · Oct 05, 2013 at 07:50 AM
Unfortunately, there isn't an inventory asset or script that you can just download. There MIGHT be one on the Unity Asset Store, but i doubt it'll be free.
An inventory system isn't entirely difficult to create, either.
A system I'm using involves creating a dictionary with slot numbers:
[C#]
//Dictionary with a key of int that represents the slot number...
//...and a IMeleeWeapon type as the value that represents each melee weapon.
Dictionary<int, IMeleeWeapon> MeleeWeaponDictionary = new Dictionary<int, IMeleeWeapon>();
Having a GUI that represents the inventory is a little more complicated, but not that hard. If you're comfortable with Unity's GUI system, then this should be pretty easy! (Otherwise, do some research!)
A Drop System: If its by Keypress, then it's relatively simple! However, it is dependent one how your game works in terms of inventory. In one of my Games, you can just pull out one of the guns you have in your inventory and then press a specific key to drop it. That would look something like this:
[C#]
private IMeleeWeapon _currentMeleeWeapon;
public KeyCode DropWeaponKey = KeyCode.D;
//The weapon dictionary uses an ID : Object system.
//Every Object (weapon) has a Unique ID assigned to it.
//Every time a weapon is added to the dictionary,
//that Unique ID is assigned to the object's index.
public Dictionary<int, IMeleeWeapon> MeleeWeaponDictionary = new Dictionary<int, IMeleeWeapon>();
public void Update()
{
//Check if the key that is used to drop the current weapon was pushed
if (Input.GetKeyDown(DropWeaponKey))
{
//If the key was pressed, remove the current melee weapon from the weapon dictionary.
MeleeWeaponDictionary.Remove(_currentMeleeWeapon.ID);
}
}
If you need any other help, comment to the answer or email/PM me!
EDIT: I urge you to check out vexe's answer and the resources he links in his answer, they may be helpful.
Also, here are a few links on Unity's GUI System:
GUI Scripting Guide - Unity Docs
GUI Script Reference - Unity Docs
If you're confused with what i did with the Dictionaries, check out this MSDN page on them:
Answer by ik1602 · Feb 03, 2015 at 01:52 PM
Since I am making second advanced version, it would really use your opinion on my first asset http://goo.gl/6Bq4Ll DIABOLIC RPG INVENTORY-FREE
p.s. I intent to post same response trough the forum whenever similar questions are ask, since I need opinions on my second asset which is advanced version of this one. I hope I am not spamming, if someone thinks that I do please let me know I'll stop immediately.Thanks.
Answer by Cherno · Oct 05, 2013 at 10:26 PM
First of all, inventory scripts are are typically fairly complex, but don't get discouraged and just start small and you will slowly get what you want.
Here's a sample inventory system that includes some advanced stuff like putting on armor on body parts and displaying them on the model, but also basic stuff like item stacks. It's an older collection but worth a look.
http://forum.unity3d.com/threads/53599-My-Contribution-Inventory-System-Free
Follow this Question
Related Questions
Issues with Inventory script 0 Answers
Inventory armor wielding proplem,How to convert from derived to base 1 Answer
Inventory loop bolt 0 Answers
Inventory List Crafting HELP 0 Answers
AddComponent Question 1 Answer