Hats stopped equipping

When I drag the hat or healthy hat into the helmet slot, it isn’t accepting it. I checked that the equip location is right and it is. I am getting one error, it seemed to happen when I dragged the hat into the slot, but not the healthy hat.
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)
This line: if (!item.IsStackable())

Okay, so extra weirdness. I closed Unity, restarted it. I drag the hat into the slot, it goes in and gives the health bonus then Unity crashes. I open it again and it’s back to not working and this time it’s the health hat that gives a null reference error. The sword works everytime so far I think btw.

After watching the next video I tested the saving and apparently that’s totally broken. Can’t save or load with the hotkeys or go through the portal. Gives me this when I try:
MissingReferenceException: The variable defaultWeapon of Fighter doesn’t exist anymore.
You probably need to reassign the defaultWeapon variable of the ‘Fighter’ script in the inspector.
UnityEngine.Object.get_name () (at <4a31731933e0419ca5a995305014ad37>:0)
RPG.Combat.Fighter.CaptureState () (at Assets/Scripts/Combat/Fighter.cs:188)

So that’s a great deal of things going on…

I’ll start with the last one… it’s quite possible that when converting the WeaponConfig from descending from ScriptableObject to descending from EquipableItem that Unity lost the serialized references in other scenes (this sort of thing happens).

Try opening up scene 2 and re-assigning the default weapons in all of the characters in the scene, players and enemies alike.

As to the next one… I’m not sure why (after 3 years!) we’re suddenly getting this error, but the solution is fairly simple:

Go into the Inventory.FindStack() method and make this minor change to the if(!item.isStackable())

            if (item == null || !item.IsStackable())
            {
                return -1;
            }
1 Like

Looks like that did it, thanks!

1 Like

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

Privacy & Terms