Unity Tutorials Inventory

Discussion in 'Scripting' started by Black Mantis, May 12, 2010.

  1. Black Mantis

    Black Mantis

    Member

    Joined:
    Feb 7, 2010
    Messages:
    1,457
    Hello all i recently purchased the inventory tutorial from the unity tutorials. and when i got it the vid was screwed up, so after asking them several times to just give a small explanation for the set up of the scripts. They insist i wait months for the new vid. So no disrespect to those guys they were very nice.(But i dont have months to wait and wanted to ask any one here that also purchased the tutorial to give a small description of where to put the scripts and how to set them up? :D Ofc it would'nt be cool for me to post the code since those guys are still selling this product :D
  2. kfrench16

    kfrench16

    New Member

    Joined:
    Mar 22, 2009
    Messages:
    73
    I bought that vid as well.

    You need to put your scripts on an empty Game object. Just like everything else in Unity, Game Objects drive the system.

    And you can follow along with the videos without their commentary.
  3. Black Mantis

    Black Mantis

    Member

    Joined:
    Feb 7, 2010
    Messages:
    1,457
    TY For the reply, I wish i could follow along with the vid, Half of it is just black screen and that i can see the audio is a few minutes off. i tried some of my video editing programs to alter the sound track but no real step in the right direction.

    I cant complain to much though, they gave me a refund, but as i mentioned to them a couple of times (via)email that they could just keep the money if they just take five minutes to explain how to set the scripts up. Its probably easy i just allready tried to tinker with it and was :? so i put it aside.
    Plus im not a blackbelt at code chi yet :D
  4. tonyd

    tonyd

    New Member

    Joined:
    Jun 2, 2009
    Messages:
    1,224
    I haven't seen the video you are referring to, but how complex an inventory system do you need?

    You can do a simple inventory using nothing more than an Array or ArrayList.

    Code (csharp):
    1. static var inventory = new ArrayList();
    Save that to a javascript named Master. You do NOT need to attach this to anything else.

    You call it from other scripts using Master.inventory, and can add/remove/display it like so:

    Code (csharp):
    1. function Start(){
    2.     Master.inventory.Add("pistol"); //add item to inventory
    3.     Master.inventory.AddRange(Array("key", "key", "ammo", "ammo")); //add multiple items
    4.     Master.inventory.Sort(); //sort inventory
    5.     Master.inventory.Remove("ammo"); //remove first instance of item
    6. }
    7.  
    8. function OnGUI(){
    9.     GUI.Label(Rect(0,0,400,50), "Inventory: " + Array(Master.inventory)); //display inventory by converting it to an array
    10. }
  5. runningbird

    runningbird

    Member

    Joined:
    Sep 3, 2009
    Messages:
    238
    The video needs to be viewed in Quick Time.

    When I watched it in Media Player the sound was off and other issues.

    I don't have the video anymore HD died and I can't contact them to get a new link etc...

    Good tutorial though.