Verse Library verse

01 Device

Iterates through all players and subscribes to their vehicle exit events for custom vehicle logic.

verse-library/exit-the-vehicle/01-device.verse

# This is our main device script.
# It runs when the game starts.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Vehicles }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We create a new device called lock_driver_device.
# This device will hold our logic.
lock_driver_device := class(creative_device):

    # This function runs when the game begins.
    OnBegin<override>()<suspends> : void =
        # We get all players currently in the game session.
        # GetPlayspace gives us access to the current game space.
        Playspace := GetPlayspace()

        # We loop over every player and subscribe to their
        # ExitedVehicleEvent. This is like giving each player
        # their own doorbell.
        for (Player : Playspace.GetPlayers()):
            # Cast the player to a fort_player so we can
            # access vehicle-related events.
            if (FortPlayer := player_is_fort_character[Player]):
                # Subscribe runs our handler every time
                # this player exits a vehicle.
                FortPlayer.ExitedVehicleEvent.Subscribe(OnPlayerExitedVehicle)

    # This handler is called every time a subscribed player exits a vehicle.
    # 'Result' carries info about which vehicle was exited.

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