Verse is a programming language developed by Epic Games that you can use to create your own gameplay in Unreal Editor for Fortnite, including customizing your devices for Fortnite Creative. Verse’s primary design goals:
- Simple enough to learn as a first-time programmer.
- General enough for writing any kind of code and data.
- Productive in the context of building, iterating, and shipping a project in a team setting, and integrating code and content.
- Statically verified to catch as many categories of runtime problems as possible at compile time.
- Performant for writing real-time, open-world, multiplayer games.
- Complete so that every feature of the language supports programmer abstraction over that feature.
- Timeless - built for the needs of today, and for foreseeable future needs, without being rooted in the past artifacts of other languages.
You’ll need to install Visual Studio Code in order to write Verse code for your UEFN Project.
Visit the Epic Games Documentation site to learn how to start in Verse with practical examples and lessons.
Modules[]
A Verse module is an atomic unit of code that can be redistributed and depended upon, and can evolve over time without breaking dependencies.
An example of how you would import a module would be:
using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary }
- Verse.org (Top Level Module)
- Verse
- Simulation
- Assets
- Colors
- Random
- Native
- Concurrency
- UnrealEngine.com (Top Level Module)
- Assets
- Temporary
- SceneGraph
- UI
- Diagnostics
- Curves
- SpatialMath
- Fortnite.com (Top Level Module)
- UI
- Devices
- InterpolationTypes
- Vehicles
- Teams
- Playspaces
- Game
- FortPlayerUtilities
- Characters
- Animation
- AI
- movement_types
In this Example, We Print a log message when ever a player spawns on a specific spawn location. This is done by using @editable attribute then assigning the desired spawner on our Verse Device.
# Modules
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
# Name of your device and it's class.
Wiki_Example_Device := class(creative_device):
# Create a customizable option for your device and the accepted targets.
@editable PlayerSpawner : player_spawner_device = player_spawner_device{}
# When the game begins this section runs instantly.
OnBegin<override>()<suspends>:void=
PlayerSpawner.SpawnedEvent.Subscribe(PlayerSpawned) # Player spawns and calls a function.
# Function called when player spawns.
PlayerSpawned(Player : agent) : void =
Print("Player Spawned!") # Prints out this message in the Log within Fortnite Client.
This snippet can be used in your game, straight out of the box. Simply copy the code and into a file, drag out the Verse Device, link the Elimination Manger.
# Modules
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
<# Typed by NeverExisted / errcode97 #>
restore_health_device := class(creative_device):
@editable EliminationManger : elimination_manager_device = elimination_manager_device{} # The device / type we are linking to Verse.
OnBegin<override>()<suspends>:void=
EliminationManger.EliminationEvent.Subscribe(RestorePlayerHealth) # Fires off the provided function when a player eliminates another agent.
RestorePlayerHealth(Agent:?agent):void=
if(Player := player[Agent?]): # Checks to see if the agent in question is an actual player.
if (FortChar:=Player.GetFortCharacter[]): # Gathers the FortCharacter from eliminator.
MaxHealth := FortChar.GetMaxHealth() # Gets the Max Health of the eliminator.
MaxShield := FortChar.GetMaxShield() # Gets the Max Shield of the eliminator.
FortChar.SetHealth(MaxHealth) # Sets the Health to Max Health.
FortChar.SetShield(MaxShield) # Sets the Shield to Max Shield.
In this Example, We set up an Array of creature spawners that Enable and Disable during a round base transaction. Which can be modified in the editor without needing to modify this Verse code.
# Modules
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
creature_control_device := class(creative_device):
#Custom User Options
@editable CreatureBlocks : []creature_spawner_device = array{}
@editable IntermissionDuration : float = 10.0
@editable RoundDuration : float = 20.0
@editable HighRoundDuration : float = 60.0
@editable HighRoundNumber : int = 10
var RoundNumber : int = 1
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Print("Running: Creature Control Device.")
spawn:
Intermission()
Intermission()<suspends>:void=
Print("Round Intermission started.")
Sleep(IntermissionDuration)
StartRound()
StartRound():void=
Print("Starting: Round {RoundNumber}")
for(AllCreatureBlocks : CreatureBlocks): #Enables all creature_spawner_device's
AllCreatureBlocks.Enable()
spawn:
HandleRound()
HandleRound()<suspends>:void=
if (RoundNumber <= HighRoundNumber): # Checks to see if the current round is considered a 'High Round' number.
Sleep(RoundDuration)
else:
Sleep(HighRoundDuration)
EndRound() # Ends the round once the Verse Timers (Sleep) are over.
EndRound():void=
Print("Round Ended")
set RoundNumber += 1 # When the round is completed increase the round number by 1
for(AllCreatureBlocks : CreatureBlocks): #Disables all creature_spawner_device's and eliminates creatures from those devices.
AllCreatureBlocks.Disable()
AllCreatureBlocks.EliminateCreatures()
spawn:
Intermission()
In this Example, We set up an Array of Elements that loops though and prints each element into the log then finishes by printing a log message telling us how many Elements were in the array.
# Modules
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
Wiki_Example_Device := class(creative_device):
# Creates our list (Array) of String Elements we want to store.
WikiArray : []string = array{"Save the World", "Battle Royale", "Creative", "Unreal Editor for Fortnite"}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
# Loops through all the Elements and prints them all.
for(WikiElement : WikiArray):
Sleep(1.0) # Delays each print by 1 second. (This is optional)
Print(WikiElement)
# Prints out only the first element.
if (WikiElement := WikiArray[0]):
Print(WikiElement)
# Prints out how long our array is.
Print("WikiArray has {WikiArray.Length} elements.")