Menu
Lumberyard
Getting Started Guide (Version 1.11)

Creating a New Trigger Area

In the previous tutorial, you removed your exit door's ability to open upon approach. However, you still want the exit door to close behind the player after exiting.

To do this, you'll create a new entity to act as the trigger area and place the trigger area on the outside edge of the maze exit door so that it triggers to close after the player exits.

To create a new trigger area for the exit door

  1. In the viewport, just outside of the exit door, create a new entity. To do this, right-click and choose Create Entity.

    In the Entity Inspector, name it ExitDoorTrigger.

  2. In Entity Outliner, drag ExitDoorTrigger into ExitDoor_Parent.

  3. Make sure ExitDoorTrigger is still selected in Entity Outliner.

    In the Entity Inspector, add the following components:

    • Box Shape

    • Trigger Area

    • Lua Script

  4. Modify the values of the Box Shape component's dimensions to X: 4.00, Y: 8.00, Z: 5.00.

  5. Use the Move tool to position the trigger area so that it is approximately two units outside of the door's exit side. Your trigger area should look similar to the following image.

  6. In the Entity Inspector, in the Lua Script component, next to Script, click the browse ('') button.

    Navigate to Scripts\Triggers. Select TriggerEvent.lua. Click OK.

  7. In the EventName box, type CloseExitDoor.

  8. Under Recipients, next to Entity, click the picker icon .

    In the Entity Outliner, select ExitDoor_Script. This places ExitDoor_Script in the Entity box.

    This points the new trigger area that you created back to the script that opens or closes the door.

  9. Press Ctrl+S to save your level.

Next: Adding a Pickup Item