Open Chest With Key

Right now i have a chest that can be opened when i press E, and there are keys that i can collect from map and get it to my inventory. How can i set that i can only open chest when i have a key in my inventory, and loose that key if it is used?

Hey @30quickdead!

So this is going to be very reliant on how you have your inventory set up. There’s no way to guess what to do in this situation. :frowning:
If you can show us with pictures how your inventory works, and show us how the chest works, we’ll be better equipped to be able to help you out!

Looking forward to more info! :slight_smile:

1 Like

Well i havent done the widget part but for example when i take a sword my animations changes that it shows i have a sword in my hand, when i have a key it just says a you collected one key with print string. I have variables to count what i have and how much i have. First image is keys bp, second and third one is my character bp. I also cant do these casts via variables when i do it from variables it just gives me error message and wont work do you know what am i doing wrong here? The bp is correct. (picture 4 and 5)




image

Cool, cool!
So where do you store your items? I see “Gained Items”, do they stay there?

Basically, on interaction with something requiring a key, you would have the thing being interacted with (chest, door, etc) ask the character if they have a key first. Here that’d be something like
Other Actor CharacterReference →
GET KeyCount → >=1? (bool check) with a branch
False path printstring “Need More Keys”, True path do your code to get the item, drag off the character reference again and SET Key Count -1 just like you do on the Gain Item event, just subtract instead of add! :slight_smile:

Hope that helps! Let us know how it goes, or if you hit a snag!