Verse Library verse

01 Device

Spawns new trap prefabs dynamically whenever players are eliminated.

verse-library/prefabs/01-device.verse

# Import the necessary Verse modules
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Playspaces }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }

# A creative_device placed in the scene acts as our spawner manager.
# It listens for eliminations and stamps out a new trap each time.
revenge_spawner_device := class(creative_device):

    # Drag your RevengeTrapPrefab asset into this field in the UEFN
    # Details panel so Verse knows which prefab to stamp.
    @editable
    TrapPrefab : creative_prop_asset = DefaultCreativePropAsset

    # OnBegin runs once when the island starts — our "Start Game" button.
    OnBegin<override>()<suspends> : void =
        # Retrieve the Fortnite game manager so we can listen for events.
        FortPlayspace := GetPlayspace()
        # Subscribe to the elimination event.
        # Every time any player is eliminated this lambda fires.
        FortPlayspace.PlayerAddedEvent().Subscribe(OnPlayerAdded)

        # Park the coroutine here so the subscription stays alive
        # for the whole match.
        loop:
            Sleep(60.0)

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