Ghost Protocol: Making Players Invisible in Fortnite
Tutorial beginner

Ghost Protocol: Making Players Invisible in Fortnite

Updated beginner

Ghost Protocol: Making Players Invisible in Fortnite

Ever wanted to build a stealth mission where players can slip past enemies like ninjas, or create a "hiding in plain sight" mechanic for a hide-and-seek game? In UEFN, making players invisible isn't just about turning off their mesh; it’s about managing their state dynamically using Verse. We’re going to build a system where specific players (let’s call them "Infiltrators") vanish the moment they spawn, only to flicker back into existence if they get hit. It’s like the storm timer for visibility—except you control when it goes up and down.

What You'll Learn

  • Variables as State Trackers: How to use a dictionary (a fancy list) to remember how long a player should stay visible.
  • The Scene Graph & Entities: Understanding that a "Player" in Verse is an Agent, and their body is a FortCharacter component attached to it.
  • Event-Driven Logic: Using SpawnedEvent to react the millisecond a player hits the map.
  • Conditional Logic: Checking a player’s team to decide who gets the invisibility cloak.
  • API Calls: Using Hide() to toggle visibility and GetFortCharacter() to reach the actual body.

How It Works

In Fortnite, you might think a player is just "the guy holding the controller." In Verse, we deal with Entities. Think of an Entity as the "Player" in your game data, and a Component as an item they are carrying or wearing. A FortCharacter is the component that holds the model, health, and visibility settings.

To make someone invisible, we don't just say "be invisible." We have to:

  1. Find the player.
  2. Find their character component.
  3. Call the Hide() function on that component.

But here’s the catch: if you just hide them, they stay hidden forever. We need a Variable (a container for data that changes, like your HP bar dropping) to track visibility duration. We’ll use a Dictionary (think of it like a loot bag where every item has a specific slot ID) to store a timer for each player individually.

We also need to know who should be invisible. We’ll check the player’s Team. If they are on the "Infiltrator" team, we hide them. If they are on the "Defense" team, they stay visible (so they can see what they’re shooting at).

Finally, we need to hook into the Game Loop. We’ll subscribe to the SpawnedEvent of the Player Spawner. This is like setting a tripwire: the moment a player spawns, our code triggers, checks their team, and applies the invisibility.

Let's Build It

Here is the core logic for an Invisibility Manager. This script assumes you have a setup where players are assigned to teams (like Infiltrators vs. Defenders).

# 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!")
        ProcessPlayer(SpawnedPlayer, Infiltrators)

    # This is the heavy lifter. It checks the team and hides the player.
    ProcessPlayer(TeamPlayer:agent, Infiltrators:team):void=
        # Get the character component from the player agent.
        # Think of this as "Equipping" the character model.
        if(FortCharacter:fort_character = TeamPlayer.GetFortCharacter[]):
            
            # Get the team this player belongs to.
            CurrentTeam:team := GetPlayspace().GetTeamCollection().GetTeam[TeamPlayer]
            
            # CHECK: Is this player on the Infiltrator team?
            if(CurrentTeam == Infiltrators):
                Logger.Print("Confirmed: Infiltrator detected. Engaging cloaking device.")
                
                # Set their visibility timer to 0. 
                # We'll explain the timer logic in the next step, but for now, 
                # we just ensure the map entry exists.
                PlayerVisibilitySeconds[TeamPlayer] = 0.0
                
                # THE MAGIC LINE: Hide the character.
                # This calls the Hide() method on the FortCharacter component.
                fort_character.Hide()
            else:
                Logger.Print("Not an infiltrator. Keeping them visible.")

Walkthrough of the Code

  1. var PlayerVisibilitySeconds:[agent]float = map{}: This creates a dictionary. In Fortnite terms, imagine a locker room. Each player has their own locker. This variable lets us store a number (seconds) inside that specific player’s "locker."
  2. PlayerSpawner.SpawnedEvent.Subscribe(OnPlayerSpawn): This is your Event Subscription. It’s like placing a pressure plate. When the event happens (a player spawns), the function OnPlayerSpawn runs automatically.
  3. TeamPlayer.GetFortCharacter[]: An Agent is the logical player entity. GetFortCharacter[] retrieves the actual 3D model component attached to that entity. You can’t hide the "idea" of a player; you have to hide their "body" (the component).
  4. CurrentTeam == Infiltrators: This is a Boolean Check. It returns true or false. If true, we run the code inside the if block.
  5. fort_character.Hide(): This is the API call. It’s the digital equivalent of pressing a button that turns off the player’s mesh renderer. They are still there, you can still hit them, but you can’t see them.

Try It Yourself

Challenge: The code above hides the player completely. But in a good stealth game, you want the player to "flicker" or become visible for a split second when they take damage, so enemies know they’re there.

Hint: You’ll need to create a new function that subscribes to the DamagedEvent of the FortCharacter. When damage occurs, you want to call fort_character.Show() briefly, then wait a few seconds, and then call fort_character.Hide() again. You can use Wait(3.0) to pause the execution for 3 seconds.

Goal: Make the infiltrator visible for 3 seconds after getting hit, then invisible again.

Recap

  • Variables store changing data (like visibility timers).
  • Dictionaries let you store data per-player using the player as a key.
  • Events (SpawnedEvent) let your code react to game moments automatically.
  • Components (FortCharacter) are what you actually manipulate to change visuals.
  • Hide() is the function that makes the character disappear.

Now go make some ninjas. The lobby isn't ready for this level of stealth.

References

  • https://dev.epicgames.com/documentation/en-us/uefn/triad-infiltration-5-making-players-invisible-in-verse
  • https://dev.epicgames.com/documentation/en-us/fortnite/triad-infiltration-10-final-result-in-verse
  • https://dev.epicgames.com/documentation/en-us/fortnite/triad-infiltration-06-blinking-player-visibility-on-damage-in-verse
  • https://dev.epicgames.com/documentation/en-us/fortnite/triad-infiltration-making-players-invisible-in-verse
  • https://dev.epicgames.com/documentation/en-us/uefn/triad-infiltration-10-final-result-in-verse

Verse source files

Turn this into a guided course

Add 5. Making Players Invisible to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in