Search Unity

How can I make an Inventory System like Rust?

Discussion in 'Scripting' started by Skyfall106, Aug 21, 2017.

  1. Skyfall106

    Skyfall106

    Joined:
    Mar 5, 2017
    Posts:
    132
    Hey! So ive been stumped for a while about how I can do this. Rust has an inventory system so you can pick things up by pressing e and then when you are in yout inventory you can click on the item and press use. Ive been looking for some other assets and example scripts that could help me find this but I am having trouble. Could anyone supply some code or help me out here. I prefer C# but JS Is ok
     
  2. Scabbage

    Scabbage

    Joined:
    Dec 11, 2014
    Posts:
    268
    Have a base class Item that items inherit from. Have an Inventory on the player (probably a good idea to use inheritance here too so NPCs or containers can use it), and create methods that allow adding/removing items to the inventory.

    That's the basic idea anyway, it's not exactly a small system that you can write up in a code snippet. Unity has a 46 minute long tutorial for inventories. 23 minutes I guess if you usually use 2x speed.