Register

method
Register<public>(Agent: agent): void

Adds `Agent` as a target when using the *CanBeHeardBy* Registered Players or NonRegisteredPlayers options.

Module
/Fortnite.com/Devices
Declared in
audio_mixer_device
Source
fortnite

Used in

if (Player := Players[Index]):
                # Register this player with their assigned reference device.
                # Register tells the Player Reference device which player
                # it is responsible for tracking.
                Ref.Register(Player)
                # Note: Register is the real API on player_reference_device
                # for assigning a player at runtime in UEFN Verse.
# Wire a placed Radio Device here.
    @editable
    DanceFloorRadio : radio_device = radio_device{}

    OnBegin<override>()<suspends> : void =
        # Register everyone already in the match, then start the music.
        Players := GetPlayspace().GetPlayers()
        for (Player : Players):
            DanceFloorRadio.Register(Player)
        DanceFloorRadio.Play()
        Print("Dance floor music started")

    # Call this to register a late-joiner so they hear the set too.
    AddListener(Player : agent) : void =
        DanceFloorRadio.Register(Player)

    # Drop the beat — silence the whole floor (e.g. for an announcement).
    KillTheMusic() : void =
        DanceFloorRadio.Stop()
# A Radio Device plays curated, looping music. Unlike the Audio Player, you
# Register the agents who should hear it, then Play(). Registering per-player
# lets each person hear their own soundtrack; Play() with nobody special
# registered plays the device's music out into the world from its position.
DanceFloorRadio.Register(Player)
DanceFloorRadio.Play()
# This function runs when the script starts. It's like loading the map.
    OnBegin<override>()<suspends>: void =
        # Here we are "Registering" an event.
        # Think of this as setting up a trap. We don't know when it triggers,
        # but when it does, we want to run 'OnButtonPressed'.
        # shop_button.ActivatedEvent.Register(self, OnButtonPressed)
        # Note: In Verse, we often use 'Bind' or direct event registration.
        # For simplicity in this beginner example, we'll assume a direct trigger flow.
        
        # Let's register the event listener.
        shop_button.ActivatedEvent += func(event: conditional_button_device_activated_event):
            OnButtonPressed(event)

    # This is a FUNCTION. A function is like a recipe.
    # It takes an input (the event) and does something.
    OnButtonPressed(event: conditional_button_device_activated_event)<suspends>: void =
        # The button was pressed AND the currency check passed!
        # Now we need to give the player the item.
        
        # Get the player who pressed the button.
        # 'event.Get_Instigator()' gets the player who triggered the event.
        player := event.Get_Instigator()
        
        if (player != null):
            # Grant the item to the player.
            # 'Grant()' is the function that says "Here, take this."
            reward_granter.Grant(player)
            
            # Optional: Send a message to the player.
            # "Thanks for your money!"
            player.Send_message("Item Granted! Enjoy your gear.")
if (not Driving?):
            DriverCamera.AddTo(Agent)
            Throttle.Register(Agent)
            SteerLeft.Register(Agent)
            SteerRight.Register(Agent)
            PaintInput.Register(Agent)
            set Driving = true
            Print("CarCapstone: driver seated -> first person + controls live.")
            spawn { DriveLoop(Agent) }
OnEnter(Agent : agent) : void =
        DriverCamera.AddTo(Agent)
        HornInput.Register(Agent)
        Print("CarFirstPerson: driver entered -> first person ON.")

    # Player got out: pop the camera and stop tracking their input.
    OnExit(Agent : agent) : void =
        DriverCamera.RemoveFrom(Agent)
        HornInput.Unregister(Agent)
OnEnter(Agent : agent) : void =
    DriverCamera.AddTo(Agent)      # gameplay_camera_first_person_device
    HornInput.Register(Agent)      # input_trigger_device

OnExit(Agent : agent) : void =
    DriverCamera.RemoveFrom(Agent)
    HornInput.Unregister(Agent)
PropHuntTemplate / Heartbeat verse-source
HeartBeatVFXData.Activate(Character.GetTransform())

            # Increment the heartbeat count, and if this is the first heartbeat playing, we need to play the audio to get it started.
            set NumberOfHeartBeats += 1
            if (NumberOfHeartBeats = 1) then SFXPlayer.Play()

            # Register the prop agent to the audio player device so the heartbeat audio will play from that position.
            SFXPlayer.Register(PropAgent)
        else:
            Logger.Print("Character, Index, or HeartBeatVFXData not found. Cannot start the heartbeat")

    # Clears the heartbeat VFX and SFX for the specified prop agent.
    Disable(PropAgent:agent, HeartBeatVFXData:heartbeat_vfx):void =
PlayerLeaderboard / Player Leaderboards verse-source
for(PlayerIndex -> PlayerAndStats : SortedPlayersAndStats, PlayerReference := PlayerReferences[PlayerIndex]):
        PlayerReference.Register(PlayerAndStats.Player)
ProceduralBuilding / Root Device verse-source
EnableBuildInputForPlayer(Agent:agent):void=
        InputDevice_Place.Register(Agent)
        InputDevice_Delete.Register(Agent)
        InputDevice_PrevCategory.Register(Agent)
        InputDevice_NextCategory.Register(Agent)

    # Disable building input for a player
    DisableBuildInputForPlayer(Agent:agent):void=