Verse Library verse

01 Device

Spawns a rescue helicopter when players interact with a placed button device.

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

# This is the main script for our rescue game.
# It connects a button device to a helicopter spawner device.

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

# We define our script here.
# This is like the name tag for our code.
helicopter_rescue_script := class(creative_device):

    # Declare the button and helicopter spawner devices.
    # Drag each device into these slots in the editor's Details panel.
    @editable
    RescueButton : button_device = button_device{}

    @editable
    RescueSpawner : helicopter_spawner_device = helicopter_spawner_device{}

    # This function runs when the game starts.
    # It sets up the connections.
    OnBegin<override>()<suspends> : void =
        # Connect the button's InteractedWithEvent to our spawn function.
        # When any player presses the button, SpawnHelicopter is called.
        RescueButton.InteractedWithEvent.Subscribe(SpawnHelicopter)

    # This function makes the helicopter appear.
    # It receives the agent (player) who pressed the button.
    SpawnHelicopter(Agent : agent) : void =
        # This line tells the spawner to create a helicopter.
        # It uses the spawner device's placement in the editor.

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