Amazing videos as usual, thanks Matt for sharing this valuable :)
@NightRunStudio
16 күн бұрын
Glad you’re enjoying the series! Best of luck getting your inventory working!
@TheRealChrisWoodward
9 ай бұрын
I had given up on Unity because I was struggling with this. I'm considering going back to it. You make this look doable. I would love to see more on building an inventory, like starting with nothing and building a game with just shapes and make a simple inventory.
@NightRunStudio
9 ай бұрын
Thanks for sharing that. I’m always glad to hear when a complex system like an inventory seems less scary in my videos! Do you mean you like to see a whole game built from scratch (including an inventory?). I’d love to do something like that eventually… it just hard to get people to keep watching a series that goes more than 5-6 videos.
@kucirulz
9 ай бұрын
Благодарим ви!
@NightRunStudio
9 ай бұрын
Thanks so much! That’s super encouraging.
@TheFrostWalker
2 ай бұрын
Very Thanks bro !
@Ambroisiewn
4 ай бұрын
Thank you so much for this tutorial, i was struggling a lot to create an inventory and this helps me a lot! I have a quick question about the sprites, the items i need to collect aren't square and once they appear in the inventory they are squished, how can i make them keep their scale?
@NightRunStudio
4 ай бұрын
There are a couple of options here. Mostly, since we have square slots, it will stretch any sprite to fill that space. So you could: 1) Use photoshop or some other visual editor to put your sprites on a square grid 2) Change your slots to match the ratio of your sprites 3) Keep square slots, but resize the actual sprite (where the item displays) so that it is not square, even though it sits on a square slot. Hope that helps!
@williamedinford3499
3 ай бұрын
Hey, i have a major problem, were NullReferenceException: Object reference not set to an instance of an object Unity show me the line `inventoryManager.AddItem(itemName, quantity, sprite);` I do script like u in all but the addItem method is not working. Thanks if u reply :)
@NightRunStudio
3 ай бұрын
null reference errors are almost always a problem inside of Unity (as opposed to the code). They usually mean that there is a box in your inspector that you have not filled in. That would be the first place I'd double check.
@williamedinford3499
3 ай бұрын
@@NightRunStudio i check if i full all fields in item script when it connected to item gameobject. All fields are full and error still existing :(
@roseprenelle8802
Жыл бұрын
Thanks for the super informative video! Loving this series. I wondered if I could ask a question. After adding in the forloop i'm getting this error in VS - ''int' does not contain a definition for 'itemSprite' and no accessible extension method 'itemSprite' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)' Any ideas what it might be?
@NightRunStudio
Жыл бұрын
This sounds like it is probably a minor copy error that is getting in the way. Usually, this means that somewhere you are mixing two types of variables. A couple of possibilities include: 1) perhaps you missed the [] when declaring your items slot array? 2) did you place itemSprite as the third item in brackets both in the FOR loop AND in your AddItem method? If neither of those possibilities seem to be the issue, feel free to paste your code here and I can take a look.
@roseprenelle8802
Жыл бұрын
@@NightRunStudio Thanks so much!! It was the latter, all sorted now and put in the same order within the brackets. Thanks for the quick reply and advice!
@NightRunStudio
Жыл бұрын
@@roseprenelle8802 Glad to hear it worked! Good luck with your project.
@username2883
8 ай бұрын
Hey, i have a major problem, were NullReferenceExeption: Object reference not set to an instance of an object InventoryManager.AddItem(System.String itemName, System.Int32 quantity, UnityEngine.Sprite itemSprite) (at Assets/Scripts/InventoryManager.cs:46) Item.OnTriggerEnter2D(UnityEngine.Collider2D collider) (at Assets/Scripts/Item.cs:35) Comes, when I am trying to pick up an Item. I hope someone can help :)
@NightRunStudio
8 ай бұрын
I’m not sure what your line 46 is, but it looks like it wants a reference to the item sprite, but can’t find it. Did you forget to fill in a box in the inspector?
@username2883
8 ай бұрын
@@NightRunStudiothank you for the fast reply, I really appreciate your work, youre helping me so much. The error is gone now, and the item is in one inventory slot after picking it up, but I cant see it in the Inventory
@NightRunStudio
8 ай бұрын
@@username2883 Hmmmn... that is a strange one. My first thought would be to look in the inspector while you are playing. Click on the slot in your hierarchy, and then check if the inspector shows data for the item. I'm wondering if maybe its just that the sprite is missing, or the slot is not enabled, or something like that.
@username2883
8 ай бұрын
@@NightRunStudio thank you so much, I had an prototype sprite inside, that was a square, because of that I couldnt see the sprite. Thank you:)
@chrisbatistarocha9159
4 ай бұрын
cant add any Item Slot to the list by dragging and dropping, anyone knows how to fix this?
@TPOKİLEBASİTİNGİLİZCE-k1f
Күн бұрын
same
@kucirulz
9 ай бұрын
I could not understand which function makes the item/item sprite appear in the inventory. Is it the loop function AddItem that adds items to the item slot array which is modified in the slot with this.itemName = itemName; this.quantity = quantity; this.itemSprite = itemSprite; etc?
@NightRunStudio
9 ай бұрын
Yes! That is the spot. The this.itemSprite = itemSprite is what makes it appear graphically, and the other stuff passes along the data about the item.
@kucirulz
9 ай бұрын
@@NightRunStudio Thank you for your fast reply, you are always very responsive, any way i can buy you a coffee, paypal or something?
@NightRunStudio
9 ай бұрын
@@kucirulz Awww... thanks for that! I do have a patreon account, and I have youtube set up to be able to do SuperThanks as well if that works better for you (there should be an icon at the bottom of each video). Thanks for the thought! Patreon: www.patreon.com/NightRunStudio
@nanhgaming27
3 ай бұрын
Please help me. Why isn't clicking the left mouse button starting the SelectedPanel?
@nanhgaming27
3 ай бұрын
The script commands from before until now are still the same as you.
@NightRunStudio
2 ай бұрын
Do you have an Event system in your hierarchy? If it got erased by accident clicking won’t work.
@Billzone_1
10 ай бұрын
for some reason I'm not able to add anything to the item slot array after creating it do you have any idea on why this is happening and how to fix it ive sorted it now no worries
@NightRunStudio
10 ай бұрын
Glad to hear it! Just for future viewers who watch this: arrays are of a fixed size, so you cannot add new elements to the array once it has been initialized. In this series, adding more slots to an inventory is handled by adding them in your original design, and then just disabling/enabling them as you want to shrink or grow the inventory.
@IzzWizard
4 ай бұрын
got everything... QuantityText needs to be enabled and the 00s need to be removed from the text box.
@tombom6431
Жыл бұрын
it is working good but i can open my inventory only once, after i close it doesnt work anymore.
@NightRunStudio
Жыл бұрын
That is usually a problem to do with your bool for menuActivated. If you go to about 6:22 in the video you can double check the code. But if it isn't opening after the first time, you may have a misplaced ! mark, or might have menuActivated set to true where it should be false (or the other way around). Hopefully that helps!
@tombom6431
Жыл бұрын
@@NightRunStudio hmmmm its working but only if i have canvas On , at the start. I had to add stop pause at the code. If i turn off the canvas then pause working but canvas do not showing on screen.
@NightRunStudio
Жыл бұрын
@@tombom6431 Have you double-checked that your inventory manager script is NOT on the canvas? In my set up, we make the canvas a child of an empty game object which is what houses the inventory manager. If your inventorymanager script is on the canvas, then you will run into trouble when you turn off the canvas. That might be the problem.
@tombom6431
Жыл бұрын
@@NightRunStudio Ok i fixed this somehow xD. I needed to put script all again to InventoryCanvas and in InventoryManager script at inspector put InventoryMenu Panel and now its working.
@NightRunStudio
Жыл бұрын
@@tombom6431 Awesome! I'm glad to hear you figured it out!
@DavidThemanoy
7 ай бұрын
If all slots in the inventory are full, does the player pick up any item or do they just leave it?
@NightRunStudio
7 ай бұрын
The player should be unable to pickup if the inventory is full.
@DavidThemanoy
7 ай бұрын
@@NightRunStudio is there a code about it?
@NightRunStudio
7 ай бұрын
Yes. It should happen by default if you follow the series. It will loop through all slots, and if there are none available, will choose not to pick up.
@Alex-cj2hi
3 ай бұрын
at 9:08 you duplicate your item slots and they automatically go next to one another. I'm trying it and each one i duplicate just goes in front in the same spot. Can anyone help pls
@NightRunStudio
3 ай бұрын
The thing that makes them go in place is the grid layout component that we added earlier. Did you maybe miss that step?
@ifeogunbanjo3682
5 ай бұрын
If I start the game with the inventory menu enabled I can click on the slots, but after I toggle on and off, it stops detecting my clicks. I'm not sure what I'm doing wrong
@NightRunStudio
5 ай бұрын
That's a weird one. It sounds like something might be turning on that shouldn't be and is may blocking the raycast... One thought would be to go to your hierarchy once you have re-enabled everything, and disable elements one at a time, trying after each one to see if clicking works. In theory, it should eventually work and that will tell you which item is blocking the raycast (or nothing will work, and then we know something else is causing the problem).
@ner0joestar917
7 ай бұрын
Hey thanks for the tutorial helped me alot, but I have a question.. the items i pick up only shows on my inventory when the panel is open, when i try to pick up the item with the panel closed it doesn't register in the inventory.
@ner0joestar917
7 ай бұрын
The problem appears to be in my inventoryManager im using a method to find the itemslot script of that certain slot using a GameObject.Find("Name") so it can't find it while the slot is off im assuming?
@ner0joestar917
7 ай бұрын
I got it working through defining the GameObjects in the class not locally in the methods, worked like a charm.
@NightRunStudio
7 ай бұрын
Sorry... I'm not totally sure I understand. Do you mean that if you pick up an item while the inventory is closed, and then open the inventory it doesn't show up? (Cause that's definitely not right). If that's not what you mean, what sort of functionality are you looking for when the inventory is closed?
@ner0joestar917
7 ай бұрын
Yea exactly what you said, it didnt show up in my inventory while the tab is closed, but it's working alright now@@NightRunStudio
@WyattMoore522
7 ай бұрын
Hey I'm having a problem where all my coding is right hopefully and I did everything in unity that you did, but when i pick up an item the data and quantity is in the menu but not the item image and I have no clue why.
@NightRunStudio
7 ай бұрын
All the magic for quantity numbers should be happening in your itemSlot script. The key line is in the AddItem method where you make quantityText.text = quantity; I would add a debug.log on the line directly before/after this line. Then you can make sure that it is executing. If that line is running, then the next possibility would be to make sure you have the correct TMP object plugged in to your inspector. Hope that helps!
@WyattMoore522
7 ай бұрын
@@NightRunStudio thanks a lot ill make sure to try this.
@tagelect5952
10 ай бұрын
bro plsssssssss help me this error: Assets\InventoryManager.cs(10,12): error CS0246: The type or namespace name 'ItemSlot' could not be found (are you missing a using directive or an assembly reference?)
@NightRunStudio
10 ай бұрын
Sounds like your InventoryManager is not able to talk to ItemSlot. It's hard to tell what's causing the error without seeing your script.
@tagelect5952
10 ай бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; public class InventoryManager : MonoBehaviour { public GameObject InventoryMenu; private bool menuActivated; public ItemSlot[] itemSlot; void Start() { } void Update() { if(Input.GetButtonDown("Inventory") && menuActivated) { Time.timeScale = 1; InventoryMenu.SetActive(false); menuActivated = false; } else if (Input.GetButtonDown("Inventory") && !menuActivated) { Time.timeScale = 0; InventoryMenu.SetActive(true); menuActivated = true; } } public void AddItem(string itemName, int quantity, Sprite itemSprite) { } }
@NightRunStudio
10 ай бұрын
Did you create the ItemSlot script? This variable is a reference to that script so if you don’t have one (or named it something different) the reference won’t work.
@tagelect5952
10 ай бұрын
yes I created the script in my ItemSlot and every thing is named like yours@@NightRunStudio
@tagelect5952
10 ай бұрын
what i fixed it@@NightRunStudio
@hunneebunn9593
9 ай бұрын
So im using a prefab as the item to collect. in the AddItem Method, how would i change the sprite for that specific prefab for the open item slot? this is probably a dumb question XD
@hunneebunn9593
9 ай бұрын
i think i just figured it out, i was confusing the AddItem method from the Inventory Manager Script, thinking they were supposed to be the same. Since im using a prefab, i had to change the information passed through the method to what was in the video XD whoops.
@NightRunStudio
9 ай бұрын
Glad to hear you sorted it out! Inventories are confusing; there’s so much going on.
@Pharaohred
10 ай бұрын
Hey dude! this is really helpful, but I'm having issues with it. Ive gotten to the end of this video (and hopefully copied all your steps, but now when i start the game, the inventory button no longer works? doesnt enable or disable the manager in any way Any help would be huge :0 Edit: if i press my inventory button whilst having the whole thing pre enabled, it just disables the primary item slot as opposed to the entire screen
@NightRunStudio
10 ай бұрын
Is your inventoryManager on the canvas or the InventoryMenu object? For the script to work it has to be on an object that is enabled. So if you put it on the root canvas, and then enable/disable the InventoryMenu object (not the canvas) it might clear up the problem.
@Pharaohred
10 ай бұрын
@@NightRunStudio Ah! it works! thanks man :) also thanks for the quick reply on a 9 month video lol.
@shonsomech7839
Жыл бұрын
gotta ask why do you make for loop if you are returning after 1 loop?
@NightRunStudio
Жыл бұрын
Goo question! You would only return after the first loop if you have found an empty slot. If the slot is full, you would skip the if statement and keep iterating until you find a different slot that is empty.
@홍서준-s8o
Жыл бұрын
I worked the same as the video, but QuantityText was not activated. What could be the problem?
@NightRunStudio
Жыл бұрын
It’s hard to know without more details. Is the text not turning on or just not updating?
@홍서준-s8o
Жыл бұрын
Yes, the text is not lit.@@NightRunStudio
@NightRunStudio
Жыл бұрын
That suggests a problem with the way things are set up in your itemSlot in Unity. Make sure that the QuantityText TMP object is turned ON for your item slot. Then, any time the slot is activated, the text should show up.
@홍서준-s8o
Жыл бұрын
@@NightRunStudio Success! thank you!! have a good day :)
@NightRunStudio
Жыл бұрын
@user-ul6zw2qj6q so glad to hear it!
@fireomatic7614
4 ай бұрын
Why is it whenever I pick an item it goes into 2 different slots??
@NightRunStudio
4 ай бұрын
That's definitely not supposed to happen... does every single item take up two slots? And, if you click on the slot in the hierarchy, does it show that it is full in the inspector?
@DeeRodriguez-kr7cw
3 ай бұрын
I’ve been having the same issue with all items, for some reason it adds to two slots. Even with the debug it executed twice, did you find a solution to fix the issue?
@NightRunStudio
3 ай бұрын
@@DeeRodriguez-kr7cw That is a weird one. Does your item have multiple colliders? Also, which method did you put the debug in?
@DeeRodriguez-kr7cw
3 ай бұрын
@@NightRunStudio The item only has a box collider and I put the debug in the addItem method on the inventory manager script. I’ve tried going over my code to see why the for loop in the addItem method is being iterated twice but I haven’t be able to fix it. Thank you for your fast response any advice is appreciated.
@NightRunStudio
3 ай бұрын
@@DeeRodriguez-kr7cw Usually, with an error like that, I try back tracking. So, next I would go to the script that calls AddItem() (I think it's called Item in this video). Right before you call AddItem, put in a debug: Debug.Log("Add Item called by " + gameObject.name); This will tell you if the method is being called twice, and hopefully also the name of the gameObject that is calling it. It sounds a little like the script has been added twice or something weird like that...
Пікірлер: 87