Verse Library verse

01 Device

Spawns a taxi and automatically seats the nearest player inside via teleportation.

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

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

# This is our main script for the Taxi Spawner.
# It runs when the game starts.
taxi_driver_script := class(creative_device):

    # We connect this property to our Taxi Spawner device
    # in the UEFN editor by selecting it in the Details panel.
    @editable
    TaxiSpawner : vehicle_spawner_taxi_device = vehicle_spawner_taxi_device{}

    # This function runs automatically when the game begins.
    OnBegin<override>()<suspends>: void =
        # Step 1: Spawn the taxi at this spawner's location.
        # We use 'Activate()' to make the taxi appear.
        TaxiSpawner.Activate()

        # Step 2: Find the player who is closest to the taxi.
        # We assume there is one player for this simple example.
        AllPlayers := GetPlayspace().GetPlayers()
        if (AllPlayers.Length > 0):
            Player := AllPlayers[0]

            # Step 3: Move the player into the taxi.
            # We use 'TeleportTo()' on the fort_character to jump the player into the car.
            # note: EnterVehicle is not yet exposed; teleporting to the spawner's
            # transform places the player at the taxi's location as a close approximation.

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