Search Unity

How to make a Simple Inventory/ Equipment System Video Tutorials (JavaScript)

Discussion in 'Community Learning & Teaching' started by Mrslayer01, Mar 24, 2014.

?

Do you find these types of tutorials easy to learn from?

  1. Yes

    70.4%
  2. No

    29.6%
  1. Mrslayer01

    Mrslayer01

    Joined:
    Mar 23, 2014
    Posts:
    30
    I have been struggling with many things with unity but I was able to solve almost all of them by using the Unity Reference, or tutorials, but I don't want to just copy and paste. I want to learn how to do these things in order to expand upon them. The one thing I looked and looked for but could not find anything that was free or was not just here is the system just copy this and it works was an Inventory System. Then I stumbled upon Jesse's videos for the advance inventory and it really stuck. So i watched his videos and developed a pretty alright Inventory System using Lists<T> in JavaScript.

    Now to help out anyone I can I had allot of time today so I figured I would make a string of video Tutorials Explaining how to use and Implement this System. I know this probably is not the best way to do this but it works and it's fairly simple to implement and understand.

    One thing I did is not release any PasteBin Links or Documents containing these scripts. I did however explain in pretty good detail how this whole system works. It took 8 videos all of them being 20 Minuets + to be sure I have fully covered everything I did in part of the script I write out.

    I encourage you to please not just copy this word for word without knowing why and try to get a basic understanding of why i did things the way I did.

    Videos on how to make this system Line By Line As well as implementing the updates can be found here:
    https://www.youtube.com/playlist?list=PLLflfFtpkLT9-1bjAXDZT7HlLcssmODgw

    Good luck guys and if you find something that I could have done better please post on the video or here so everyone will know.

    Edit: Hey guys a quick fix for the scroll bar I noticed since I put it in the for loop it creates multiple scroll bars on top of each other and that will slow down performance so basically all you need to do to fix this:
    1. Move the scrollposisiton = GUI.Scrollbar right under the GUI.DrawTexture and make sure it is outside of the for loop.
    2. Go all the way down to the end of the for loop and move GUI.EndScrollView(); down one bracket or in other words outside of the for loop but still inside of the _display if statement so it only shows when you press tab.

    Edit 2: I gave up on attachments because it stalls out after it finishes uploading, so I just linked the download from drop box If this is not allowed please let me know I'm sorry if i'm breaking the rules!

    Edit 3: Changed the title from a Simple Inventory / Equipment System to an Advanced Inventory / Equipment System, Cause that what this turned into..

    Update 1: I have just released a video on how to make the items description show up when you left click it and Equip / UnEquip Items when you right click. This is a massive stepping stone for showing just how easy it would be to implement say a quest System that uses the same basic setup as this. Or even an action bar! The new video can be found in the Play List above.

    Update 2: Just a quick fix addressing a few things with the inventory system. This includes Sorting the items alphabetically, as well as clearing the description when clicking on another tab(for instance clicking on the equipment screen while in the inventory screen) The video showing how to is in the playlist above.

    A few notes:
    • These videos show you how to completely make this Inventory/Equipment System line by line.
    • I wont provide any assets for this system as I want you to learn from this and not just copy and paste.(You will thank me later)
    • Any credits go to Jesse for the initial Idea.
    • I did all of these videos in a single day so by about video 4 It shows but I resolve all of the problems and finish successfully
     
    Last edited: Apr 21, 2015
  2. Mrslayer01

    Mrslayer01

    Joined:
    Mar 23, 2014
    Posts:
    30
    For this update I go in depth on how to show the items description when you click on them, As well introduce the use of Events for our buttons so we can make them do a certain thing depending on if we Left or Right click.

    Check out the video in the play-List above again I will not be providing any of this completed system for download but I do explain how to do it Line by Line.
     
  3. Mrslayer01

    Mrslayer01

    Joined:
    Mar 23, 2014
    Posts:
    30
    For Update Number 2 I just decided to do a short video that shows how to go about fixing a few bugs as well as sorting our inventory alphabetically. So I hope you guys enjoy and as always if you have question post them here or on the video it self.
     
  4. Sk8rseth

    Sk8rseth

    Joined:
    Aug 4, 2013
    Posts:
    13
    great job on the series man. it really helped me understand not only how the inventory would (should) work, but it also gave me a firm grasp on Javascript as a whole. thank you so much!
     
  5. DubstepDragon

    DubstepDragon

    Joined:
    Dec 6, 2012
    Posts:
    7
    Oh man, JavaScript... Not only is it inefficient as a language, it's also hard to understand and not as clean as C#. Is there any way you can provide a C# copy, or will I have to translate it myself?

    Also, thanks for the awesome work! :p
     
  6. Ignisor

    Ignisor

    Joined:
    Jan 14, 2015
    Posts:
    4
    Maybe you can do like this for change slots to empty

    Code (csharp):
    1.  
    2. function Update () {
    3.     if (update)
    4.     {
    5.         Empty();
    6.         update = false;
    7.     }
    8. }
    9.  
    10. function Empty()
    11. {
    12.     for (var i:int = 0; i<5; i++)
    13.     {
    14.         if (!equipmentList[i].equipped)
    15.         {
    16.             equipmentList[i] = (ItemHandler(0, itemIcon, '', '', false, ItemType.Helm, 0, 0));
    17.         }
    18.     }
    19. }
    20.  
    I don't know does it work, but must work.