Setting Up The Level
To get started, initialize a new project from the Fall Guys Starter island template. This starter island contains a ready-made course for you to navigate through, and you’ll customize it with movement in this tutorial.
Defining Props that Move
Before you can start moving your props, you need to define what a movable prop is. You could use a Verse device to move a prop directly, but this might get tricky if you wanted to move multiple props at once. Instead, you’ll define an abstract movable_prop class. This will contain the prop you want to move and several other values that you’ll use to customize the logic and timing of your movement.
Follow the steps below to define your movable prop:
Create a new Verse class named
movable_propusing Verse Explorer. Because this is a Verse class and not a device, create this file using Create Empty. And since this will be the abstract class that you’ll subclass different types of movable props from, add the<abstract>specifier to this class. To learn how to create a new class in Verse, see Modify and Run Your First Verse Program.Verse# Defines a Creative prop that moves to a target or location using animation. movable_prop<public> := class<abstract>():Add the
using { /Fortnite.com/Devices },using { /Verse.org/Simulation }, andusing { /UnrealEngine.com/Temporary/SpatialMath }import paths to the top of your file. You’ll need to import these module to handle the math that makes your props move.Each of the fields in this class will also include a
ToolTip. Adding aToolTipmessage to your editable fields displays a tooltip when you mouse over the field in UEFN. All the tooltips used in this class are included below. You can copy and paste these tooltips, or define your own.Verseusing { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } MoveDurationTip<localizes>:message = "The amount of time the prop takes to move to its destination." MoveEaseTypeTip<localizes>:message = "The animation easing applied to the movement." MoveEndDelayTip<localizes>:message = "The delay after the movement finishes." MoveOnceAndStopTip<localizes>:message = "Whether the RootProp should stop in place after it finishes moving." MoveStartDelayTip<localizes>:message = "The delay before the movement starts." MoveTargetsTip<localizes>:message = "The array of CreativeProp to move toward. These targets can be children of the RootProp."Define the fields each movable prop needs. To your
movable_propclass definition, add the following fields:An editable
creative_propnamedRootProp. This is the Creative prop you’ll move around during gameplay.Verse# The Creative prop associated with this class. # This should be the root prop of the object you want to move. @editable {ToolTip := RootPropTip} RootProp:creative_prop = creative_prop{}An editable
floatnamedMoveDuration. This is the amount of time the prop takes to reach its destination.Verse# The duration in seconds it takes for the prop to move to its destination. @editable {ToolTip := MoveDurationTip} MoveDuration:float = 3.0An editable
floatnamedMoveStartDelay. This is the time in seconds the prop waits before moving.Verse# The duration in seconds to wait before movement begins. @editable {ToolTip := MoveStartDelayTip} MoveStartDelay:float = 0.0An editable
floatnamedMoveEndDelay. This is the time in seconds the prop waits after moving.Verse# The duration in seconds to wait after movement ends. @editable {ToolTip := MoveEndDelayTip} MoveEndDelay:float = 0.0An editable
logicnamedMoveOnceAndStop. This controls whether your prop only moves once, or repeats movement after it finishes.Verse# Whether the RootProp should stop in place when it finishes moving. @editable {ToolTip := MoveOnceAndStopTip} MoveOnceAndStop:logic = falseAn editable
logicnamedShouldReset. This controls whether your prop resets to its original position after it finishes moving.Verse# Whether the RootProp should reset back to the starting position when it # finishes moving. @editable {ToolTip := ShouldResetTip} ShouldReset:logic = falseA variable transform named
StartingTransform. This is the transform theRootPropis at when it starts movement.Verse# The starting transform of the RootProp. var StartingTransform:transform = transform{}
Your final class definition should look like this:
Verseusing { /Fortnite.com/Devices } using { /Fortnite.com/Devices/CreativeAnimation } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/SpatialMath } MoveDurationTip<localizes>:message = "The amount of time in seconds the prop takes to move to its destination." MoveEaseTypeTip<localizes>:message = "The animation easing applied to the movement." MoveEndDelayTip<localizes>:message = "The delay after the movement finishes." MoveOnceAndStopTip<localizes>:message = "Whether the RootProp should stop in place after it finishes moving." MoveStartDelayTip<localizes>:message = "The delay before the movement starts."Before your prop moves, it needs to know where it’s moving from. To do this, you’ll define a new function to set the
StartingTransformbefore movement:Add a new method
SetStartingTransform()to yourmovable_propclass definition.Inside
SetStartingTransform(), set theStartingTransformto the transform of theRootPropusingGetTransform().Your complete
SetStartingTransform()function should look like this:Verse# Sets the StartingTransform to the current transform of the RootProp. SetStartingTransform():void= set StartingTransform = RootProp.GetTransform()
To start moving your prop, you’ll define a new function
Move():Add a new method
Move()to yourmovable_propclass definition.Add the
<suspends>modifier so this function can run asynchronously. Because this is the base class version of this function and won’t be used, justreturnimmediately.Your complete
Move()function should look like this:Verse# Move the RootProp to its target. This is the base class # version of this function and should not be used. Move()<suspends>:void= return
If you want your prop to reset when it finishes moving, you need to teleport it back to its starting position. To handle this, add a new method
Reset()to yourmovable_propclass definition:Add the
<decides><transacts>modifiers to this function to allow it to roll back in case the reset fails. This could occur if your prop was disposed of during gameplay.Inside
Reset(), teleport theRootPropback to itsStartingTransformusingTeleportTo[].Your complete
Reset()function should look like this:Verse# Reset the RootProp by teleporting it back to its Starting Transform. Reset()<decides><transacts>:void= RootProp.TeleportTo[StartingTransform]
You’ve defined a lot of functions, and now it’s time to tie them all together. To manage all the different movement functions, add a new method,
ManageMovement(), to yourmovable_propclass definition. Add the<suspends>modifier to let this function run asynchronously.Verse# Loops moving the RootProp to its target by calling Move(), and handles # any logic when the movement begins and ends. ManageMovement()<suspends>:void=In
ManageMovement(), create aloopexpression that manages the movement. Inside the loop, firstSleep()forMoveStartDelayseconds, then callMove().Verse# Loops moving the RootProp to its target by calling Move(), and handles # any logic when the movement begins and ends. ManageMovement()<suspends>:void= loop: Sleep(MoveStartDelay) Move()When your platform finishes moving, it needs to keep going, reset its position, or stop in place. To handle stopping, in an
ifexpression, check ifMoveOnceAndStopis true. If so,breakout of the loop. After movement stops,Sleep()forMoveEndDelayseconds. Finally, in anotherifexpression, check ifShouldResetis true and callReset[]if so. Your completeManageMovement()function should look like this:Verse# Loops moving the RootProp to its target by calling Move(), and handles # any logic when the movement begins and ends. ManageMovement()<suspends>:void= loop: Sleep(MoveStartDelay) Move() # If the prop should only move once and stop, then exit the loop. if:Since there’s no
OnBegin()function in this class, you need a way for other classes to callManageMovement()to start moving your platform. Add a new functionSetup()to yourmovable_propclass definition. InsideSetup(), first callSetStartingTransform(), then spawn aManageMovement()function to get your platform going. Your completeSetup()function should look like thisVerse# Set the StartingTransform, then begin movement by spawning ManageMovement. Setup():void= SetStartingTransform() spawn{ManageMovement()}
Next Up
With your abstract class complete, in the next step, you’ll figure out how to get them moving through animation!
Complete Code
Here is the complete code built in this section:
movable_prop.verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Devices/CreativeAnimation }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
MoveDurationTip<localizes>:message = "The amount of time in seconds the prop takes to move to its destination."
MoveEaseTypeTip<localizes>:message = "The animation easing applied to the movement."
MoveEndDelayTip<localizes>:message = "The delay after the movement finishes."
MoveOnceAndStopTip<localizes>:message = "Whether the RootProp should stop in place after it finishes moving."
MoveStartDelayTip<localizes>:message = "The delay before the movement starts."