Sitemap

How to Unlock the Door with a Looted Item.

2 min readAug 3, 2025

Before start learning about this system, which is built on top of previous features, to understand, start from the beginning of my article about the game logic Interaction project, especially if you are a beginner.

Here is a Link for the whole series from the beginning

Game Logic and Interactable II

9 stories

Now, go back to the Door script and create a bool variable and an itemType variable.

Press enter or click to view image in full size

Create a method with a bool return type that takes AllItems as a parameter. Check if we have itemRequired in the list of inventory items; if true, we need to return true; else, we will return false.

Press enter or click to view image in full size

Go to the Interact method inside the else statement, check if _requiresItem is true, then check if HasRequiredItem returns by passing _requiredItem as a parameter. Then, unlock the Door by calling the Activate method and setting the parameter to true, but if the condition is false, then we will tell the player to check the Terminal.

Note: The last Debug is when the door dont _requiresItem when _requireItems is false and the door is locked, the last debug will be called.

Press enter or click to view image in full size

In this step, I will unlock the door after collecting the key, but first, go to the Inspector and check _requiresItem if you want this door to be open by lootItem.

Press enter or click to view image in full size

See into the next one.

--

--

Suleiman Abdullah
Suleiman Abdullah

Written by Suleiman Abdullah

My name is Suleiman Abdullah. I learn game development and share what I learn by writing articles. :https://ko-fi.com/suleimanabdullah

No responses yet