Trigger action¶
When designing an event that triggers another event in your game, it is essential to implement the Trigger Action logic mechanic in the scene. Any triggering mechanics will inevitably involve the mechanic.
In the horror game template, the Trigger Action is a component that involves a trigger event and an action event. When the trigger is activated, the corresponding action is executed. Let's start with the most basic configuration.
Adding the Trigger Action component to your object¶
-
Select the object in the scene and view its properties by choosing the More icon.
-
In the Properties window, choose + Feature and you can add the Trigger Action component.
-
After adding the Trigger Action component, you can edit its triggering mechanic in the Properties window. For more information about the component, see Trigger action.
Tutorial: Setting a cube that automatically hides when players enter its trigger box¶
In this example, we will demonstrate how to hide a cube when players enter its trigger box.
-
Create a cube to be a trigger zone In Scene Explorer, click the + icon and choose 3D object>cube to add a cube to the scene.
-
Add the Trigger Action component Select the cube, then click the More icon to open its properties window. In the panel, click + Feature to open the Add Feature window, search for Trigger Action, and add it to the cube.
-
Set the Trigger Action component Drag the cube into the Trigger Entity and ActionEntity, select the trigger as EnterTriggerZone(Player) and HideObject as the action, leaving Delay at 0. These settings imply that when the player enters the cube's trigger zone, the cube is immediately hidden.
-
Adjust the cube's collider and trigger box Remember to turn off the collider (so the player can enter this zone) and add a trigger box (set the scale of the trigger zone). You can also configure the appearance of the cube to make it more visible or not.
Now, it's time for you to playtest: