Verse Library verse

01 Standalone

Detects vehicle or player crossing a finish line trigger and declares the first winner to end the race.

verse-library/build-a-carracing-game-in-unreal-editor-for-fortnite/01-standalone.verse

# This is our main script. It's like the race director.
# We attach this to the Finish Line Trigger.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is the device we are coding. 
# Think of it as the "Brain" of the Finish Line.
FinishLineDevice := class(VerseDevice):

    # VARIABLE: This tracks if the race has already been won.
    # It's like a flag. Once it's up, no more winners allowed.
    RaceFinished := false

    # EVENT: This runs automatically when a car enters the trigger volume.
    # It's the "Elimination Feed" for our finish line.
    OnEnter := event(Other: Entity):
        # Check if the thing entering is a player/car.
        # We use 'Is' to check the type, like checking if a loot item is a shield.
        if (Other.Is(Player) || Other.Is(Vehicle)):
            
            # Check if the race is already over.
            if (RaceFinished == false):
                
                # Set the flag to true. The race is done!
                RaceFinished = true
                
                # Call our custom function to handle the win.
                # It's like pressing the "Victory Royale" button.
                DeclareWinner(Other)

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

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