Automatically opening a door after collecting all items
This tutorial is intended for Horror Game Kit users.
In this tutorial, you will use the Counter component to track collectible pickups and trigger the door to open automatically once all collectibles are gathered.

This step-by-step process will help you create interactive gameplay elements that respond to player actions. Here's the workflow:
- Configure the door using door-related smart assets.
- Configure collectibles using the Collectable Item smart asset.
- Use the Counter and Event Trigger components to automate door opening.
Setting up the door
Locate the door smart assets and customize the door model.
-
Navigate to Packages > Horror Game Assets and find the Unlocked Door smart asset (alternatively, use the Locked Door and Key asset.
-
Customize the door model as needed:
-
Use the default door model if it fits your design.
-
To replace the model, select the object labeled Smart and update the model in the Properties panel. Refer to the Model Replacement Guide for detailed instructions.
-
Setting up collectibles
Locate the Collectable Item smart asset and customize the collectible model. The scene has five collectible objects, each corresponding to one of the five collectible assets. Make sure your configuration matches this setup.
-
In Packages > Horror Game Assets, find the Collectable Item smart asset.
-
Customize the collectible model: Use the default model or replace it via the Properties panel.
-
Create five collectible objects in your scene, each using the Collectable Item smart asset.
Automating door opening with Counter and Event Triggers
For the gameplay logic, we need the door to automatically open when all collectibles are picked up. Here's how to set up the logic:
Adding an empty object
Create an empty object from the Quick Create panel. This object will hold the Counter and Event Trigger components.

Adding and configuring the Counter component to the empty object
-
Select the empty object, open the Properties window, and add the Counter component from the Horror Logic package.
-
Configure the Counter component on the empty object:
Property Description Notify Key Value Event Enable to notify whenever changes, e.g., from 1 to 5. Key Value The target count. Set this to 5 for collecting five collectible objects. For more details, see the Counter.
Adding and configuring an Event Trigger component to the empty object
-
Add the Event Trigger component to the empty object.
-
Configure the trigger:
Event Description Object Self (the empty object itself) OnKeyValueReached Triggered when the KeyValue reaches the target count. Then set the action:
Action Description Object Specify the unlocked door. Open The specific behavior of the target object, such as the door opening.
Add and configure Event Trigger to each collectible
Add an Event Trigger component to each collectible. Configure the event OnPickedUp to trigger an action that tracks the number of collected items, and send an Increase action to the Counter object to increment the count.

Event Trigger
Event | Description |
---|---|
Object | Self (the collectible itself) |
OnPickedUp | Triggered when the target object is picked up. |
Then set the action:
Action | Description |
---|---|
Object | Specify the empty object with the Counter component attached. |
Increase | Increase the Counter’s KeyValue by 1, e.g., from 0 to 1. |
When the first collectible object is picked up, the KeyValue counter increments from 0 to 1. Subsequent collectible objects follow the same logic; each time an object is collected, the KeyValue count increases until it reaches 5.

Testing in Play Mode
With all components configured, enter Play Mode to test the counting logic. Collect all five items and observe the door opening automatically upon completion.
Troubleshooting
If the door does not open after collecting all items, verify that:
- The Counter's Notify Key Value Event is enabled.
- Each collectible's Event Trigger correctly targets the Counter object with the Increase action.
- The door's Event Trigger is properly set to respond to OnKeyValueReached.