quinta-feira, 14 de agosto de 2025

UEFN Verse: Rush (Time Flow)

Rush is a time flow control expression that executes other expressions concurrently and ends as soon as one of the expressions in its block completes. However, the other expressions within the Rush continue to execute.

The code below shows a simple example of the rush expression: 

    OnBegin<override>()<suspends>:void=

        rush:
            Car1.MoveTo(Car1_Destination, Car1_Rotation, Car1_MoveTime)
            Car2.MoveTo(Car2_Destination, Car2_Rotation, Car2_MoveTime)
            Car3.MoveTo(Car3_Destination, Car3_Rotation, Car3_MoveTime)
            
        Print("One of the cars reached the finish line")

Car1Car2 and Car3 are instances of creative_prop. The MoveTo() function moves the creative_prop to the position and rotation passed as a parameter for the specified time duration.

As soon as one of the MoveTo functions completes, the rush expression will also complete, and the Print() function will execute. Even after the rush expression completes, the other MoveTo functions will continue executing until they complete.

To illustrate the use of the rush expression, let's simulate a simple car race. To keep the example simple, each car moves in a straight line until it reaches the position indicated by a creative_prop. Each car's race time will be set randomly.

In any UEFN project, open Verse Explorer, right-click on the project name and choose the Add new Verse file to project option.

In Device Name put rush_device and click the Create Empty button.

Copy the Verse code below into the rush_device file:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }

rush_device := class(creative_device):

    @editable
    Car1 : creative_prop = creative_prop{}

    @editable
    Car2 : creative_prop = creative_prop{}

    @editable
    Car3 : creative_prop = creative_prop{}

    @editable 
    EndLocation1 : creative_prop = creative_prop{}

    @editable 
    EndLocation2 : creative_prop = creative_prop{}

    @editable 
    EndLocation3 : creative_prop = creative_prop{}

    @editable
    MinTime : float = 10.0

    @editable
    MaxTime : float = 20.0

    OnBegin<override>()<suspends>:void=

        Car1_Destination := EndLocation1.GetTransform().Translation
        Car1_Rotation := Car1.GetTransform().Rotation
        Car1_MoveTime := GetRandomFloat(MinTime, MaxTime)

        Car2_Destination := EndLocation2.GetTransform().Translation
        Car2_Rotation := Car2.GetTransform().Rotation
        Car2_MoveTime := GetRandomFloat(MinTime, MaxTime)

        Car3_Destination := EndLocation3.GetTransform().Translation
        Car3_Rotation := Car3.GetTransform().Rotation
        Car3_MoveTime := GetRandomFloat(MinTime, MaxTime)

        Winner := rush: 
            block:
                Car1.MoveTo(Car1_Destination, Car1_Rotation, Car1_MoveTime)
                "Car 1"
            block:
                Car2.MoveTo(Car2_Destination, Car2_Rotation, Car2_MoveTime)
                "Car 2"
            block:
                Car3.MoveTo(Car3_Destination, Car3_Rotation, Car3_MoveTime)
                "Car 3"    

        Print("WINNER: {Winner}")

The rush expression in the example above has three blocks with MoveTo() and a string that will be the result of the rush expression.

The rush expression was used in this example so that the other cars continue moving to the end even after the first car has arrived.

Save the file and compile the Verse code using the Verse > Build Verse Code option from the UEFN menu.

Access the Content Drawer and add our rush_device to the level. The example needs three creative_prop representing the cars and three creative_prop indicating the cars' destinations.

For the cars, I used the Car Rat, Car Pickup, and Car Stocker. Search for them in the Content Drawer. For the destinations, I used three instances of Racetrack Flag. The track was made with a Road Straight 1x1 and a Road Straight 1x1 Finishline. 

Select the rush_device in the level. In the Details tab, add the creative prop references.


Save the level and click the Launch Session button to load the level into Fortnite. Watch the race and see that the other cars continue to move even after the first car has won the race and completed the rush expression.


Table of Contents Verse