Verse Library verse

01 Use Third Person Controls In Verse

Shows how to programmatically assign third person controls to all players and remove them after a delay.

extracted-snippets/documentation/en-us/fortnite/using-third-person-controls-devices-in-fortnite-creative/01-use-third-person-controls-in-verse.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/using-third-person-controls-devices-in-fortnite-creative
# Local doc:  epic-docs/documentation/en-us/fortnite/using-third-person-controls-devices-in-fortnite-creative.md
# Section:    Use Third Person Controls In Verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# A Verse-authored creative device that can be placed in a level
gameplay_controls_third_person_device_verse_example := class(creative_device):
# Reference to the Gameplay Control: Third Person Device in the level.
# In the Details panel for this Verse device,
# set this property to your Gameplay Control: Third Person Device.
@editable
MyThirdPersonControlsDevice:gameplay_controls_third_person_device = gameplay_controls_third_person_device{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("Adding third person controls to players.")
# This example iterates through all players in the experience to show how to do operations per player on the device.
for (Player : GetPlayspace().GetPlayers()):
# Adds the camera to the `Agent`'s camera stack and pushes it to be the active camera.
MyThirdPersonControlsDevice.AddTo(Player)
# Wait 5 seconds
Sleep(5.0)
Print("Removing third person controls from players.")
# Removes the camera from all `Agent`'s camera stacks and pops from being the active camera replacing it with the next one in the stack.
MyThirdPersonControlsDevice.RemoveFromAll()

Comments

    Sign in to vote, comment, or suggest an edit. Sign in