Event trigger
When you're designing a game event that either triggers itself or another event, it's really important to use the Event Trigger logic mechanic in your scene. This mechanic is essential for any triggering mechanisms you plan to include in your game.
In the horror game template, the Event Trigger is a component that consists of a trigger, condition groups, and an action list. Here's how it works: When the trigger is activated and the specified condition is met, the corresponding action is executed.
To make it simpler, think of it as a way to set up events in your game that happen automatically based on certain conditions being fulfilled. It's like creating a cause-and-effect relationship, where you specify what needs to happen for a specific action to occur.
Let's start with the most basic setup for this configuration.
Adding the Event Trigger component to your object
-
Select the object in the scene and view its properties by choosing the More icon.
-
In the Properties window, choose Add Event Trigger and you can continue to add the component. Or, you can choose Add Components and select the event trigger component.
-
After adding the Event Trigger component, you can edit its triggering mechanic in the Properties window. For more information about the component, see Event Trigger.
Tutorial: Setting a cube that shows narrator when players enter its trigger zone
In this example, we will demonstrate how to shows the narrator when players enter the cube's trigger zone.
-
Create a cube in Scene Explorer, click the + icon and choose 3D object >cube to add a cube to the scene.
-
Create a Trigger Zone as the child object of the cube, press the right mouse button, and choose Create child object>Trigger Zone to add it. For more information about the component, see Trigger Zone.
-
Change the size of the trigger zone as you prefer. Make sure to adjust it so that it covers the cube. When you enter the trigger zone, the associated actions will be activated.
-
In the properties window of the cube. Add a Narrator component. And fill in the content as you like. For more information about the narrator component, see Narrator.
-
Open the Properties window of the cube, then click the Add Event Trigger button.
-
Customize the trigger's properties and settings following these steps:
- Drag the Trigger Zone object into the Trigger Object field.
- Choose OnTriggerZonePlayerEnter as the trigger event.
- Set Action Object as the cube itself and select ShowNarrator as the action.
- Keep the delay at 0 for immediate action.
These settings make the cube show the narrator when the player enters the trigger zone.
Now, it's time for you to playtest: