To create the opening scene where the player is part of the cutscene, you need to teleport the player to the basement after the opening cutscene finishes playing. To do this, you’ll use the code snippet below:
AllPlayers := GetPlayspace().GetPlayers()
for (Agent : AllPlayers):
Teleporter.Teleport(Agent)
This piece of code is designed to grab all players on your island and apply a function to them. In this case, teleportation.
Teleporting Players after a Cutscene
Create a new Verse device named cutscene_trasnporter using Verse Explorer, and drag the device into the level. Double-click cutscene_transporter.verse from Verse Explorer to open the script in Visual Studio Code.
Underneath the transporter_device class definition, add editable fields for the following devices:
CinemtaicSequence
Teleporter
PlayerSpawner
Versecutscene_transporter := class(creative-device): @editable CinematicSequence : cinematic_sequence_device = cinematic_sequence_device{} @editable Teleporter : teleporter_device = teleporter_device{}
Add a new method
TeleportPlayers()to theteleport_deviceclass. This method teleports each player to the teleporter you set up in the sub-basement. Add the code snippet from earlier to theTeleportPlayers()method.VerseTeleportPlayers():void= AllPlayers := GetPlayspace().GetPlayers() for (Agent : AllPlayers): Teleporter.Teleport(Agent)In
OnBegin(), subscribe theStoppedEventfrom yourCinematicSequenceto theTeleportPlayers()method. SubscribingTeleportPlayers()this event causes the device to listen for theStoppedEventof theCinematicSequence, then executes the method TeleportPlayers below.VerseOnBegin<override>()<suspends>:void= Print("Loading Cutscene") CinematicSequence.StoppedEvent.Subscribe(TeleportPlayers)Your
teleporter_devicecode should now look like the following:Verseusing { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } ## A Verse-authored creative device that can be placed in a level log_transporter_device := class(log_channel){} transporter_device := class(creative_device): @editableSave the script in Visual Studio Code, and in UEFN, click Build Verse Code.
Place the Player Spawner in the parking lot of the Durr Burger, and the Teleporter should be placed in the holding area of the sub basement.
Select the teleport_device in the Outliner and assign the Cinemtaic Sequence, Player Spawner, and Teleporter devices to their respective properties in the Details panel.
Click Push Changes to playtest the code.
When the cutscene begins, the player should begin in the Durr Buger parking lot. Once the cutscene finishes playing, the player should be teleported to the basement where the game begins.
Next Section
In the next step of this tutorial, you’ll learn how to use cinematics both drive the story and create mood and atmosphere.