Verse Library verse

01 Device

Spawns a player chosen sports car when they press a trigger button in a garage zone.

verse-library/using-sports-car-spawner-devices-in-fortnite-creative/01-device.verse

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

# This is our main script.
# It controls the garage.
MyGarageDevice := class(creative_device):
    # This is the spawner.
    # It will make the car appear.
    # note: Assign this device reference in the UEFN details panel after adding the Verse device to your island.
    @editable
    car_spawner : sports_car_spawner_device = sports_car_spawner_device{}

    # This is the trigger.
    # It detects when a player steps on it.
    # note: Assign this device reference in the UEFN details panel after adding the Verse device to your island.
    @editable
    start_button : trigger_device = trigger_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # We listen for the button press.
        # When the button is pressed, we call "OnButtonPressed".
        start_button.TriggeredEvent.Subscribe(OnButtonPressed)

    # This function makes the car appear.
    OnButtonPressed(agent : agent) : void =
        # We check that the agent is a player before spawning.
        if (player := player[agent]):
            # This line tells the spawner to spawn a car.

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