Verse Library verse

01 Fragment

Hides specific teams upon spawn by tracking visibility timers and subscribing to spawn events.

verse-library/5-making-players-invisible/01-fragment.verse

# invisibility_manager.verse

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

# This is our "Loot Bag" of data.
# Key: The Player (Agent)
# Value: How many seconds they have left to be visible (float)
var PlayerVisibilitySeconds:[agent]float = map{}

# This is the main script class. It runs when the game starts.
class InvisibilityManager<public>(World:world) extends VerseWorld():

    # This function starts everything up.
    StartInvisibilityManager<public>(AllTeams:[]team, AllPlayers:[]player, Infiltrators:team):void=
        Logger.Print("Invisibility Protocol Activated!")
        
        # 1. Subscribe to the Spawn Event.
        # This means: "Every time a player spawns, run OnPlayerSpawn."
        for(PlayerSpawner:PlayersSpawners):
            PlayerSpawner.SpawnedEvent.Subscribe(OnPlayerSpawn)
        
        # 2. Handle players who already spawned before the script started.
        for(TeamPlayer:AllPlayers):
            ProcessPlayer(TeamPlayer, Infiltrators)

    # This function is called whenever a new player spawns.
    OnPlayerSpawn(SpawnedPlayer:agent):void=
        Logger.Print("New infiltrator spotted!")

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