(HELP) how to see if list contains certain scriptable objects

followed this bmo tutuorial but I’m doing an adventure game and want to do an inventory check for an item (for example, you can’t go through a certain door unless you have a certain key, etc.) but I’ve tried list.contains over and over and I can’t figure it out.

Anybody know a good way to check inventory list for certain items? (note: I can’t just type if(inventory.Contains(“Red Key”) or something because I get a “Can’t convert type inventory item to type string” error.)

Here’s the tutorial in case anyone wants more info, this is basically exactly what I did.

Thanks in advance!

List<T>.Contains wants a value that matches the type of the list.

So in the case of a locked door, give the door component a reference to the SO you want to check for (by exposing it in the inspector and dropping in the right SO), then you can use that reference in List.Contains.

1 Like

You solved my problem spiney, thank you! For anybody else who may stumble upon this in the future-- I had to reference the itemdictionary, not the inventory list. I think it was because the itemdictionary is what holds the itemdata scriptable object stuff. Not sure, this is all a little over my head but it works now to so there you go! Thanks again spiney!

1 Like