Null Reference with pickups in inventory

Hello every one !

I have the following mistake:

NullReferenceException: Object reference not set to an instance of an object
GameDevTV.Inventories.Inventory.FindStack (GameDevTV.Inventories.InventoryItem item) (at Assets/Asset Packs/GameDev.tv Assets/Scripts/Inventories/Inventory.cs:207)
GameDevTV.Inventories.Inventory.FindSlot (GameDevTV.Inventories.InventoryItem item) (at Assets/Asset Packs/GameDev.tv Assets/Scripts/Inventories/Inventory.cs:177)
GameDevTV.Inventories.Inventory.HasSpaceFor (GameDevTV.Inventories.InventoryItem item) (at Assets/Asset Packs/GameDev.tv Assets/Scripts/Inventories/Inventory.cs:49)
GameDevTV.Inventories.Pickup.CanBePickedUp () (at Assets/Asset Packs/GameDev.tv Assets/Scripts/Inventories/Pickup.cs:64)
RPG.Control.ClickablePickup.GetCursorType () (at Assets/Scripts/Control/ClickablePickup.cs:21)
RPG.Manager.PlayerManager.InteractWithComponent () (at Assets/Scripts/Manager/PlayerManager.cs:274)
RPG.Manager.PlayerManager.Update () (at Assets/Scripts/Manager/PlayerManager.cs:59)

it seems to be very familiar to that one https://www.udemy.com/course/unityinventory/learn/lecture/17957838#questions/10831884
:
NullReferenceException: Object reference not set to an instance of an object

GameDevTV.Inventories.Inventory.FindStack (GameDevTV.Inventories.InventoryItem item) (at Assets/GameDev.tv Assets/Scripts/Inventories/Inventory.cs:207)

GameDevTV.Inventories.Inventory.FindSlot (GameDevTV.Inventories.InventoryItem item) (at Assets/GameDev.tv Assets/Scripts/Inventories/Inventory.cs:177)

GameDevTV.Inventories.Inventory.HasSpaceFor (GameDevTV.Inventories.InventoryItem item) (at Assets/GameDev.tv Assets/Scripts/Inventories/Inventory.cs:49)

GameDevTV.Inventories.Pickup.CanBePickedUp () (at Assets/GameDev.tv Assets/Scripts/Inventories/Pickup.cs:64)

RPG.Control.ClickablePickup.GetCursorType () (at Assets/Game/Scripts/Control/ClickablePickup.cs:21)

RPG.Control.PlayerController.InteractWithComponent () (at Assets/Game/Scripts/Control/PlayerController.cs:87)

RPG.Control.PlayerController.Update () (at Assets/Game/Scripts/Control/PlayerController.cs:46)

but unfortunnately the following solution doesn’t works:

  1. if(item==null)
  2. {
  3. Debug.Log($"{name} does not have an InventoryItem set.");
  4. return;
  5. }

Also, when i add a weapon pickup Unity refuses to work, the only option is to reboot.

Will be very glad if some one will give a solution.

Thank you in advance.

Post your ClickablePickup.cs script here. Don’t forget to format it using the </> button.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms