Verse Library verse

01 Fragment

Spawns a sportbike at a player position upon stepping into a trigger volume without duplicates.

verse-library/using-sportbike-spawner-devices-in-fortnite-creative/01-fragment.verse

# Import the necessary Verse libraries for game logic and devices
using /Fortnite.com/Devices
using /Engine/Systems/GameUserSettings

# This is our main "Script" object. Think of it as the brain of our island.
# It holds our logic and connects to our devices.
class BikeSpawnScript is GameScript():
    
    # VARIABLE: A slot to hold a reference to our Sportbike Spawner device.
    # We'll link this in the editor later.
    SpawnDevice: SportbikeSpawnerDevice = SportbikeSpawnerDevice{}

    # VARIABLE: A boolean flag (true/false) to track if a bike is currently spawned.
    # Like a light switch: ON or OFF.
    is_bike_spawned: bool = false

    # EVENT: This function runs automatically when a player enters the Trigger Volume.
    # "Player" is the person who stepped on the pad. "Volume" is the trigger itself.
    OnBeginOverlap(Player: Player, Volume: TriggerVolume) -> void:
        # CHECK: Is a bike already there?
        if is_bike_spawned == true:
            # If yes, do nothing. We don't want two bikes in one spot.
            # You could add a sound effect here to tell the player "No Room!"
            return
        
        # ACTION: Spawn the bike at the player's current location.
        # We use the SpawnDevice we linked earlier.
        # The bike will appear facing the same direction the player is facing.
        SpawnDevice.SpawnVehicle(Player.GetTransform())

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