Search Unity

Inventory Tutorials

Discussion in 'Community Learning & Teaching' started by drew_massey, Aug 23, 2013.

Thread Status:
Not open for further replies.
  1. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Hey guys,

    Drew here from Acem Gaming bringing you a set of tutorials to help you get started on making inventories for your game. This tutorial series is designed to help teach you the basics of inventory design so that you can use the knowledge to make your own custom inventories for your games. This is a work in progress series, but listed below are the links to the tutorials made thus far.

    Part 1 : Introduction to Inventories : https://www.youtube.com/watch?v=bEL00R_4R7k
    Part 2 : GUI Setup : https://www.youtube.com/watch?v=iyaSvEQqsPk
    Part 3 : Item Dictionary : https://www.youtube.com/watch?v=AhjCGy1O4gA
    Part 4 : Looting Corpses : https://www.youtube.com/watch?v=N4zd624n6xU
    Part 5 : Adding Multiple Items : https://www.youtube.com/watch?v=a4QJr-51HCY
    Part 6 : Loot Control (Random vs. Fixed) : https://www.youtube.com/watch?v=ony2qD4vOX4
    Part 7: Loot Control (Continued) : https://www.youtube.com/watch?v=kqQSOEKp42k

    If you have any questions on how to do anything in this series feel free to ask, and i'll gladly help!

    -Drew
     
    Last edited: Sep 16, 2013
  2. dirtydan

    dirtydan

    Joined:
    Jun 24, 2013
    Posts:
    6
    i have painstakingly searched and have found nothing to help me with this, i know pretty much nothing about GUI's and all that, but I'm going to start at the basics a little later, first im trying to find some tutorial on how to do an inventory system like penumbra, or amnesia the dark descent. i really enjoy those games and want to make horror puzzle games like them, and the most important thing, having the inventory system, escapes me. do you know how to make an inventory system like that??????
     
  3. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
  4. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    dirtydan,

    You are going to need GUI knowledge in order to build an inventory because an invenotry is essentially all GUI. I have a link to a GUI series if you need help learning how to code the GUI.

    This series will teach you how to make a basic inventory which you can adapt to your game however.

    Link to GUI tutorials : http://forum.unity3d.com/threads/195050-Unity-GUI-Design-Tutorials
     
  5. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    Excellent job, Drew.

    This has been a commonly requested series.

    Best,

    Jon
     
  6. dirtydan

    dirtydan

    Joined:
    Jun 24, 2013
    Posts:
    6
    the gui part has many tutorials and i am able to learn that, the part that I'm trying to get at, is where you double click on an item, a guy icon of it appears where your cursor is, then you click on an in game object, then an animation plays, with that setup VERY VERY MANY things can be done, and im just basically asking, can that be done in unity, can it replicate the inventory system of amnesia/penumbra?
     
  7. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    Dirty,

    Anything you can think of can be done in Unity3D. Every game that's ever been created, can be created in Unity3D. Games that have never existed, can be created in Unity3D.

    Where is everyone getting this "Can Unity3D make a game like..." from?


    To answer your question though, yes! :) You can easily create that type of inventory system if you create it with the GUI.

    His Menu, all the items are just buttons, and when you add a texture, you can basically have it set to where when you click a box, your equipment animation will happen, etc. Or whatever function you want.

    Best,

    Jon.
     
  8. dirtydan

    dirtydan

    Joined:
    Jun 24, 2013
    Posts:
    6
    ok thanks, its just i have been searching for guides and i couldn't find anything for the style of inventory that i have been looking for, almost every inventory thing i find is for an mmorpg or some equipment rpg inventory and i don't need to know how to do that, i've just been solely trying to find out how to do a simple double click on a guy image, that can trigger animations, which apparently is hard for me to find
     
  9. dirtydan

    dirtydan

    Joined:
    Jun 24, 2013
    Posts:
    6
    thanks for all your help by the way
     
  10. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Part 4 is out! This one will expand upon the concept of the item dictionary as well as show you how to make lootable corpses. As always thank you everyone for your support, and if you have any questions feel free to ask and I will try to get back to you as soon as possible.

    Part 4 : Looting Corpses : https://www.youtube.com/watch?v=N4zd624n6xU
     
  11. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Thank you Subzero for assisting dirtydan with your explanation.

    This tutorial series will show you how to build an inventory system that you can adapt to whatever type of game you want to do. It will go over the basics, but it is up to you to make the adaptations. It wouldn't make sense for me to make your inventory so that you can profit off of it. That being said however, if you get stuck at anytime, you are more than welcome to ask me questions on how to do certain things and I will try to assist you. Please don't ask me to make the whole thing though, but I will answer questions if you get stuck.

    Thank you,
    -Drew
     
  12. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Part 5 of the series is out!

    In part 5 I will show you how to add multiple items to your inventory. Now you can have more than one arrow!

    Hope you enjoy. If you have any questions or comments let me know!

    -Drew


    Link : https://www.youtube.com/watch?v=a4QJr-51HCY
     
  13. dirtydan

    dirtydan

    Joined:
    Jun 24, 2013
    Posts:
    6
    yeah, i wouldn't ask you to make it for me, i just want someone to point me in the right direction
     
  14. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Part 6 of the Series is out!

    In part 6 I will teach you how to control the loot dropped. Topics will be randomized loot and fixed loot.

    Hope you enjoy, if you have any questions feel free to ask!

    -Drew

    Link : https://www.youtube.com/watch?v=ony2qD4vOX4
     
  15. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    I need a little bit of help.

    I've gone through part 4, and when I click on a button on my inventory, the game stops because of a NullReferenceException: Object reference not set to an instance of an object on my loot script. The same also happens if I click a loot button.

    The error is pointing me to line 42 of Robot_loot.cs
    I'm also getting warnings about adding monobehaviors with the 'new' keyword, versus using Addcomponent if that means anything.

    here are my scripts

    View attachment $Inventory.zip (2.15 kb)

    Any help would be greatly appreciated.
     
  16. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Part 7 of the inventory series is out!

    In part 7 we will fix the issue at the end of part 6 where we would only see one set of loot options for multiple loot corpses. After part 7 you should have a fully functioning loot control that will only need to be slightly tweaked in the future.

    Hope you enjoy, if you have any questions feel free to ask and I will try to resolve your issues.

    -Drew

    Link : https://www.youtube.com/watch?v=kqQSOEKp42k
     
  17. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Hey SecondBake,

    I recommend going through part 5, because the structure is going to change from one script handling all of the inventory to two scripts.

    However, even without part 5 the script should work. When you say the game stops does it exit out of play mode? You should be getting a NullReferenceException because right now we are working with String.Empty which is just a null string. This will be fixed in part 8 when we go over making icons, because we will make an empty icon for when we don't have anything in that slot.

    Line 42 of your script is pointing towards the point in which you check if you have clicked on a game object with the tag denoting it is a lootable corpse, but everything checks up with your script as long as you made sure that you assign the corpse the correct tag in the editor.

    Where are you getting the errors "adding monobehaviors with the 'new' keyword, versus using Addcomponent" I've never received an error like that, so i'm unsure why you are getting that. But when you created the ItemClass class did you put a : Monobehaviour? The : Monobehaviour that is auto generated each time you create a .cs script is inheriting all of the variables and methods in the Monobehaviour class which allows you to use various methods such at LookAt(); The new ItemClass that you create doesn't need to inherit that which may cause an issue.

    I'll continue to look through your script, but from what I can see so far it looks fine. Keep debugging as well and maybe go back through the videos to see if you missed anything, and let me know if you figure it out.

    I'll let you know as well if I find anything.

    -Drew
     
  18. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    Yeah, it's odd. I hit play, and the game runs fine until I click on one of the gui buttons - it just pauses the game, and gives me the error. Beforehand, I had the inventory toggle on a checkbox (like in the video), and the game would "crash" when I turned on the inventory at all. I thought it may have to do with the toggle switch, so I replaced it with getkeydown and getkeyup and that's where I'm at now. Any button I press crashes the game.

    It must have something to do with the raycasting and tags. I comment out the if statement on line 42 and the looting seems to work. I've tried adding different tags, and making sure the tag was spelled correctly, and my syntax was okay, but to no avail.

    Here is the warning. It doesn't reference any script and gets sent every frame.





    I think I will take a look at part 5 then. Perhaps that will expose whatever bug is in there. Who knows, I may have to do this all over...

    Thanks, I appreciate it. I'll let you know when I figure out the problem.

    I have learned an abundance from these tutorials thus far. I new next to nothing anout things like the gui system, and hadn't worked with dictionaries or complex classes yet. Thanks for putting these out. :)
     
  19. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    HAHA YES

    I figured out the problem!
    The error was caused when the raycast didn't hit any colliders on mouseclick - thus returning the null reference.
    Placing a huge plane in the backdrop fixed the issue, but that's sort of a band-aid. I'd like know how to prevent that error without having a backdrop in place (to account for the chance that the user would click the sky).

    Thanks again for the tuts. Really enjoying this series.
     
  20. drew_massey

    drew_massey

    Joined:
    Apr 28, 2013
    Posts:
    94
    Excellent, I'm glad that fixed it temporarily!

    That's weird that was the issue though. I still get the error message that you are talking about, but my game doesn't crash after.. unless are you playing the built game, and it is crashing?

    I think a fix would be have the if statement check to see if the ray hit anything. The way our if statement is set up though I would think it would cover that, but perhaps not.

    I'm glad that you are enjoying my tutorials!

    -Drew
     
  21. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    Nice job Drew. I'm glad to see you are keeping up with this series. Keep up the good work!

    Best,

    Jon
     
  22. Edan

    Edan

    Joined:
    Oct 3, 2013
    Posts:
    2
    Please make turn base rpg tutorial like Final Fantasy series
     
  23. Black-pearl

    Black-pearl

    Joined:
    Mar 20, 2014
    Posts:
    55
    Hey Acem

    These tutorials are awesome never thought of doing it this way its cool,
    I wondered used to use variables to store the inventory but i cant figure out how to store a dictionary to maybe a string?
    Google returns garbage?!

    Cheers
     
  24. AaronC5513

    AaronC5513

    Joined:
    Oct 31, 2015
    Posts:
    5
    How do I make items appear in the first person? I'm concerned I'll get a null pointer exception.
     
  25. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,670
    Please don't resurrect dead threads. This thread was last active over 3 years ago. If you have any questions, create a new thread and ask the authors to respond. Usually, however, once something like this has reached its end of life, there won't be much response.
     
Thread Status:
Not open for further replies.