I have an equipment manager i call this from to add or remove items when something is equipped from a item. It all works exactly the way i want, except when i first equip an item at the very start, it always adds the item with the id of 0. Since im using an id set up for my itemdata base and using classes, it will always be 0 even if set to null. Not sure how to make it not do this at the start.
I believe you are misunderstanding something here. IDs are numbers. Unassigned object variables are null by default. Unassigned number variables are 0 by default. You cant have a number be null, since it’s not an object.
Hope this helps, as i’m not entirely sure why you’d want the ID to be null in the first place.
Maybe i’m misunderstanding your problem tho.
I know the id or number cant be null, the issue is, at the start i add a few items, when i go to equip the very first item, it removes the item i want to equip but also adds an item to the inventory it shouldnt from the item data base because the item is id number 0, because the function i use requires i return a id. So since it cant be null it always adds item id 0. Im using Past item to keep track of the current item equipped so i can return it to the inventory since im equipping a different item in its place. Which works fine, but at the very start, past item is 0 by default so it gets added in the inventory when i equip something when i dont need it to
Cant you just instantiate the past item id to some invalid id, like -1, on startup? This allows you to handle the case differently and not add some “random” item to your inventory simply because it got 0 as id.
So what i did is set armorSlot.id to being -1 at the start of the game and it ended up working. This is a good work around for now till i can come up with something a little better lol Thanks for the help!