Verse Library verse

01 Device

Initializes a race session and resets the score manager when the game begins.

verse-library/design-a-car-racing-game-in-fortnite-creative/01-device.verse

# This is our main script. It runs the race logic.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# We make a new type of object for our race.
# Think of this as a blueprint for our game brain.
RaceController := class(creative_device):

    # We declare the Score Manager as a property.
    # Drag your Score Manager device onto this slot in the editor.
    ScoreMgr : score_manager_device = score_manager_device{}

    # This function starts when the game begins.
    OnBegin<override>()<suspends>: void =>
        # We wait for the game to start.
        # This is like waiting for the flag to drop.
        Sleep(1.0)

        # Now we tell the Score Manager to reset.
        # ScoreMgr is wired up in the editor, so it is always found.
        ScoreMgr.ResetScores()
        Print("Race is ready! Go!")

Comments

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