Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

My Contribution - Inventory System - Free

Discussion in 'Made With Unity' started by ExDeaDguY, Jul 7, 2010.

  1. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Hello everyone, I'm Eddy.

    I've worked on a few games on unity and posted them so some of you may have seen my work in progresses! But anyways, I wanted to make a small contribution to the Unity3d community. So here you go!

    Webplayer:
    https://dl.dropbox.com/u/6629353/InventorySystem.html



    Since I've noticed a lot of people wanting to work on games but not knowing any scripting, I decided to make a very basic, *and by basic I mean really really simple* inventory system.

    This is heavily commented.

    This is mainly aimed at people learning unitys JS. It may not be perfect, or pretty but it works :p.


    Source:
    http://dl.dropbox.com/u/6629353/InventorySystem.zip


    Use this however you want :p.



    If you're looking for a fully customizable inventory system with a lot of great features I highly recommend you check this out:

    http://www.youtube.com/watch?v=KyOEwoXf-6k

    Good Luck fellow developers! :).



    Be sure to check out these threads:
    Advanced Inventory Equipment System
    Simple Inventory - Free
    Simple Health Bar - Free
     
  2. tatelax

    tatelax

    Joined:
    Feb 4, 2010
    Posts:
    1,145
    Thanks but how would you make it so you can delete objects? Please reply!
     
  3. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Okay I updated it with the ability to remove items from your inventory by clicking them, Hopefully this achieved what you needed done :). To literally destroy something, Remove the item from the list the same way i did when moving it to the ground but instead use Destroy(gameObject); That would most likely do it.

    Let me know if anything works incorrectly or needs to be fixed.
     
  4. joel

    joel

    Joined:
    Jun 12, 2010
    Posts:
    117
    To make this very interesting script even more interesting you could perhaps make different items that can be assigned to the player.

    like picking up an armor piece can only be assigned in the armor slot.
    and that armor piece would be assigned to the player model.
    (easiest would be to give the player model a skeleton, and rig the armor piece to the same skeleton, but save it as a separate model)

    I'm sure people would be willing to pay for that, even more then $5 i know i would :)
     
  5. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Awesome - Yeah, and I could call this the Indie version, And that the Full version. I think I will deffinetly make a pimped out version of this. An update will probley be ready in a few days so keep a look out.
     
  6. joel

    joel

    Joined:
    Jun 12, 2010
    Posts:
    117
    @Xeno360, if you need any help with some art assets. let me know. i'd be happy to help you out.
    items/characters/rigging
     
  7. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Hey guys, Wanted to let everyone know i havn't forgotten about this! :p. Im working on an "Advanced System", that will be released shortly (day or so hopefully).
     
  8. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,036
    This is looking pretty cool. The biggest problem I've found in creating an inventory system is coming up with a good way to save and load that inventory between game sessions. Would love to see your take on that.
     
  9. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Well, Ive actually just finished the inventory system and am waiting for it to be uploaded for a release. But, To take care of that problem wouldnt be to hard. Just recreate the inventory each time you load a game.

    Ex:

    Set up a list of items that could possibly be collected while playing.


    Then at the end of the game session use player prefs to store some integers

    item 1=4;
    item 2=1;

    etc. And then just have it re-create the invnetory with the saved int's when loading

    Inventory.Add(availibleitems[item1]) and so on.

    Thats how id do it at-least. :p
     
  10. msborat

    msborat

    Joined:
    Jun 17, 2010
    Posts:
    89
    How to change the Back Drop to a GUI Box
     
  11. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,036
    Just remove the existing line of code that sets the background image, and use a GUI.Box instead. e.g.

    Code (csharp):
    1. GUI.Box(Rect(0,0,640,480), "Inventory");
     
    Origxn likes this.
  12. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Yeah! What he said! ^.^
     
    Ichimaru913 likes this.
  13. crasyboy42

    crasyboy42

    Joined:
    Jun 29, 2010
    Posts:
    28
    nice man :D
    this saves me about 10$

    can you make a script that the people can equip the armor? to the character??
    that would be nice :D
     
  14. RoyS

    RoyS

    Joined:
    Jan 12, 2009
    Posts:
    632
  15. Xsnip3rX

    Xsnip3rX

    Joined:
    Aug 29, 2009
    Posts:
    197
    Hey you can make me some scripts :), i need:

    With a quote of how complex i think they are next to the names.

    Phaser's from Star Trek ($5)
    Torpedos ($1)
    Targetting System ($4)
    Shields ($3)
    Damage ($3)
    Pulse disruptors ($1)
     
  16. antrock101

    antrock101

    Joined:
    Dec 19, 2009
    Posts:
    88
    is there a way to extend this for point and click style inv, it goes into your inv, but i want to select a item to use it so then i can use code such as

    if item selected == spade and in hole trigger

    dig

    somthing like that
     
  17. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,036
    @Xeno360 - have you tried this out in Unity3 at all? I'm trying to get it working but running into issues within the following code:

    Code (csharp):
    1.  
    2. var Contents : GameObject[];
    3.  
    4. function AddItem(Item : GameObject) {
    5.     var newContents = new Array(Contents);
    6.     newContents.Add(Item);
    7.     Contents = newContents.ToBuiltin(GameObject);
    8. }
    9.  
    This produces an error:

    (on the final Contents = ..... line)

    Used to work fine in Unity iPhone 1.7. Seems to be a lot of these casting/typing changes in Unity3.
     
  18. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    Thats odd >.<. I Dont have Unity3 yet, But when I get my hands on a copy and figure out what the changes are and what not I'll update this :). Sorry about that.
     
  19. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455





    Hmmm.. I booted it up in unity 3, and it runs fine for me. No errors at all. Only thing I noticed different while using it with unity 3, is when dropping the boxes. You can get stuck inside its collider now >.<, (I guess colliders work while inside and out now? :p ). Maybe if you redownload the package and re-compile it in unity 3 it will work.


    -Eddy
     
  20. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,036
    Thanks for checking. Which build platform are you set to when testing?

    I'm finding a lot of my Unity iPhone stuff isn't working anymore in Unity 3, but seems to work for other people. I'm wondering if it's something specific to setting Unity 3 to the iPhone build platform, or maybe some specific setting I have turned on.
     
  21. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455

    I only build web-players. and PC - Standalone :p. (this works with both) Sadly I don't have an iPhone or I'd be developing some cool stuff for it ^.^
     
  22. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,036
    Seems like the problem might be related to the new requirement to have "#pragma strict" directive for collider.Raycast to work. If that's added, then your code breaks and will no longer compile. Such a pain in the butt.

    Oh well... I'll post here if I get it working eventually. Thanks for your help! :)

    (More Info)
     
  23. podda999

    podda999

    Joined:
    Apr 26, 2010
    Posts:
    69
    Thanks mate, massive kudos.
     
  24. Chmyke

    Chmyke

    Joined:
    Aug 1, 2012
    Posts:
    11
    Hi Eddy,
    I'm trying to save the inventory, but i don't understand something:
    when you say : Set up a list of items that could possibly be collected while playing.
    it's a list of what? Of Gameobject?
    like
    var item1: GameObject;
    var item2: GameObject;
    var item3: GameObject;


    and then, how do you do to transform this item to int for store it?
    Maybe by adding a var ID to the Item script? And after use a GetComponents to get it?
    Right?
    I'm sorry I started with Unity...
    And thank you for sharing this system!
     
  25. MRPoof

    MRPoof

    Joined:
    Jul 17, 2012
    Posts:
    1
    I have spent hours banging my head on the table trying to figure out how to do an inverntory. Thank you for making the bump on my head go away.
     
  26. Exagerate

    Exagerate

    Joined:
    Feb 16, 2013
    Posts:
    13
    Agreed, i've used this code and adapted it a lot. I would love to know how to make the items stackable (if stackable is enabled) though!
     
  27. Tonis

    Tonis

    Joined:
    Jun 29, 2013
    Posts:
    13
    Can you please write me a simple script. I want the character to collect objects then use them once. So i needa simple inventory with no limit and i want to check via script if the character has the needed object, if he does...true if he does't false.
     
  28. moddymod06

    moddymod06

    Joined:
    Dec 12, 2013
    Posts:
    4
    Please can i have some characters and such
     
  29. townsendmedia

    townsendmedia

    Joined:
    Apr 9, 2014
    Posts:
    2
    I am trying to use this for an idea i have...with a little tweeking, it just might work!
    thanks:D
     
  30. yoieyo

    yoieyo

    Joined:
    Jun 24, 2014
    Posts:
    4
    Can you make it so it opens the inventory when you press a key, for example e?
     
  31. Origxn

    Origxn

    Joined:
    Jun 27, 2014
    Posts:
    42
    just realized this is from 2010. Do u have anything more updated?
     
  32. astralislux

    astralislux

    Joined:
    Aug 8, 2014
    Posts:
    10
    And in C#?
     
  33. ExDeaDguY

    ExDeaDguY

    Joined:
    Aug 25, 2009
    Posts:
    455
    No, I'm sorry. I have been working on an actual project lately. If you're looking to make an inventory system they are actually very easy.. Learn a little C#, grab this or another inventory system, rip it apart and find out how the equipping and all of that is done and then make your own using the techniques you have learned. :)

    That's the best way to do it :p. The 2 inventory systems I made are more of a learning guide instead of a implement into your project and expect a fully working inventory that does it all :p
     
  34. PlanetAlexander

    PlanetAlexander

    Joined:
    Jul 3, 2015
    Posts:
    1
    I chose this inventory system over others because it will help me learn javascript/C# a little better. But I'm not sure if my inventory is right. It appears in the top left hand corner, with all the boxes going down the page and the words on the left of them names like "Window Position". Can you show us what it is meant to look like, and how to use it properly? The demo doesn't work right in Unity5. Also, is there a way to bind a button to bring up the inventory? Thanks!