Unable to cast object of type error 'inventory_item' to type 'inventory_slot'

click on one of these:

and expand it, I am wondering what is in there.

I would clear out all of the array elements on the player inventory, add one empty one and then drag an ‘inventory_slot’ resource into it, as that is the type of resource that array is wanting. If you drag in an ‘inventory_item’ resource into it, you will get the type mismatch.

This is the path incase that helps:

res://resources/misc/PlayerInventory.tres::Resource_sft8j

I don’t see an inventory_slot resource, or one doesn’t pop up at least. Would I just create one?

so find that .tres file in the filesystem,

resources/misc/PlayerInventory.tres

double click it, in the inspector on the right, what is the script associated to it named?

inventory_array

well right now the Slots array on the player inventory object (which uses the inventory_array script) is expecting an ‘inventory_slot’ as seen below:

so then you need to drop a resource that is an inventory_slot object type, so if you don’t have that setup, you’ll want to make those. Then in those, you will assign the Name and Texture like you see here:

Then drop those new .tres inventory_slot objects into that inventory_array Slots array, and that should match up.

2 Likes

That worked! Thanks so much for your help. :smile:

1 Like

good to hear.

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