Verse Library verse

02 Device

Automatically respawns an SUV immediately when destroyed or when a player exits it.

verse-library/using-suv-spawner-devices-in-fortnite-creative/02-device.verse

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

infinite_suv_script := class(creative_device):

    # Reference to the SUV Spawner — assign it in the UEFN details panel.
    @editable
    SuvSpawner : suv_spawner_device = suv_spawner_device{}

    # OnBegin: subscribe to both events we care about.
    OnBegin<override>()<suspends> : void =
        # 1. Vehicle was destroyed (exploded, fell off map, etc.)
        SuvSpawner.VehicleDestroyedEvent.Subscribe(HandleVehicleDestroyed)

        # 2. A player exited the vehicle under their own power.
        # 'AgentExitedVehicleEvent' is the real listenable on suv_spawner_device.
        SuvSpawner.AgentExitedVehicleEvent.Subscribe(HandlePlayerExited)

    # Handler: vehicle destroyed
    HandleVehicleDestroyed(Instigator : ?agent) : void =
        Print("Boom! Respawning SUV.")
        SuvSpawner.Activate()

    # Handler: player voluntarily exited
    # The event delivers the agent (player) who stepped out.
    HandlePlayerExited(ExitingAgent : agent) : void =
        # If the player just gets out, respawn the vehicle immediately
        # so the next player (or the same one) always finds a fresh SUV.
        Print("Player bailed! Respawning SUV.")

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