Puzzle mechanics can be integrated into many game genres — adventure, RPG, platformers, and FPS to name a few. They can also stand on their own as a complete game experience if the puzzles are engaging. The same puzzle setup can even be reused multiple times in the same game if you specify different initial conditions and solutions for each puzzle.
In this puzzle, the player must find the right combination of lights — all on in this case — by interacting with buttons. Each button toggles a set of lights. When the puzzle is solved, an item is spawned as a reward.
By following this tutorial, you'll learn how to create a version of this puzzle where you can customize the start states of the lights, which lights each button toggles, and the puzzle solution, all by using one device created with Verse in Unreal Editor for Fortnite (UEFN).
Verse Language Features Used
array
: The device you will create extensively uses arrays to perform its logic. Buttons, lights, lights state, event handlers and more are stored in arrays to allow varying puzzle configurations (more or fewer lights, different start and goal light states), and to prevent code duplication.for
: With thefor
expression, you can iterate over the arrays the device uses.if
:if
is used to check when the puzzle is solved, filter the devices found viaGetCreativeObjectsWithTag()
and control the lights state.failure
: Failure contexts are used to access arrays, detect when the puzzle is solved, and control the flow of the program.class
: In addition to thetagged_lights_puzzle
creative device class, you’ll create the class for the buttonInteractedWithEvent
handlers to enable per-event properties.
Verse APIs Used
- Editable Properties: Multiple Verse-authored device properties are exposed to UEFN so you can customize them in the editor. You’ll be able to create new puzzle configurations by changing these properties.
GetCreativeObjectsWithTag()
: With theGetCreativeObjectsWithTag()
API, you can find all devices tagged with a customizable Gameplay Tag at runtime without exposing the references in the editor. In this case, the lights are tagged with thepuzzle_light
tag.- Device Events: The buttons’ InteractedWithEvent are used to control the game state.
Steps
Follow these steps to learn how to create a puzzle where the player needs to find the right combination of lights to spawn an item. The complete script is included in the final step for reference.