How Can I Call A Function In Verse For A Player That's In A Specific Class?

Say I want to show a hud message for a specific class that the player picks, how would I go about that using verse? I know the class designer in the fortnite digest has the “GetMembersOfClass” and “IsOfClass” but I’m not sure how to actually make a function using those two in order to achieve this.

I’m fairly certain those two functions are broken, or I haven’t been able to get them to work appropriately. Instead, I’ve opted to listen to “ClassSwitchedEvent” on my individual class_and_team_selector_devices. If you do this, you can store a map of player and ints and approriately assign an int based on the specific ClassSwitchedEvent that fired, and thus later reference the map do your “call a function in verse for a player that’s in a specific class” end goal.

Heres a snippet of code you can modify to implement what I suggest. You’ll notice I have 4 different classes that each fire a different method when switched to, and then prints the appropriate log. You’ll be able to apply this same concept for what you are currently trying to build. Good luck.


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

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
class_change_debugger_device := class(creative_device):

    @editable
    NoSpectateClassChange : class_and_team_selector_device = class_and_team_selector_device{}

    @editable
    SpectateClassChange : class_and_team_selector_device = class_and_team_selector_device{}

    @editable
    LobbyClassChange : class_and_team_selector_device = class_and_team_selector_device{}

    @editable
    RemoveInvinsibilityClassChange : class_and_team_selector_device = class_and_team_selector_device{}


    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        NoSpectateClassChange.ClassSwitchedEvent.Subscribe(AlertClassChanged1)
        SpectateClassChange.ClassSwitchedEvent.Subscribe(AlertClassChanged2)
        LobbyClassChange.ClassSwitchedEvent.Subscribe(AlertClassChanged3)
        RemoveInvinsibilityClassChange.ClassSwitchedEvent.Subscribe(AlertClassChanged4)


    AlertClassChanged1(Agent:agent):void=
        if (Player := player[Agent]):
            Print("Class Changed NoSpectateClassChange ")


    AlertClassChanged2(Agent:agent):void=
        if (Player := player[Agent]):
            Print("Class Changed SpectateClassChange ")


    AlertClassChanged3(Agent:agent):void=
        if (Player := player[Agent]):
            Print("Class Changed LobbyClassChange ")


    AlertClassChanged4(Agent:agent):void=
        if (Player := player[Agent]):
            Print("Class Changed RemoveInvinsibilityClassChange ")

Thank you for replying, we just used the ClassChangedEvent for the Class Selector UI Device

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.