My user interface is not showing for everyone

hello here is my code, it displays the number of players in my boxfight, however I made it display only for players entering a certain zone (using a mutator zone) however the ui does not display for all people who enter the mutator zone, can you help me please?

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



# 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
objectif := class(creative_device):

    @editable
    Zonealte: mutator_zone_device = mutator_zone_device{}

    @editable
    zoneUI: mutator_zone_device = mutator_zone_device{}
    
    var  Objective : int = 0
    var Players : []player = array{}
    var MaybeMyUiPerPlayer : [player]?canvas = map{}
    

    OnBegin<override>()<suspends>:void=
        Zonealte.AgentEntersEvent.Subscribe(OnMutatorZoneEnter)
        Zonealte.AgentExitsEvent.Subscribe(OnMutatorZoneLeft)
        zoneUI.AgentEntersEvent.Subscribe(HandleButtonInteraction)
                
    
    HandleButtonInteraction(Agent : agent) : void =
        if (InPlayer := player[Agent], PlayerUI := GetPlayerUI[InPlayer]):
            if (MyUi := MaybeMyUiPerPlayer[InPlayer]?):
                PlayerUI.RemoveWidget(MyUi)
                if (set MaybeMyUiPerPlayer[InPlayer] = false) {}
            else :
                NewUI := CreateMyUI()
                PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.None})
                if (set MaybeMyUiPerPlayer[InPlayer] = option{NewUI}) {}



    OnMutatorZoneEnter(InAgent : agent):void=
        set Objective += 1
        UpdatePlayerlCount(Objective)
        Print("{Objective}")

    OnMutatorZoneLeft(InAgent : agent):void=
        set Objective -= 1
        Print("{Objective}")
        UpdatePlayerlCount(Objective)

    
    PlayerText<localizes>(objecti : int) : message = "PLAYER LEFT IN THE MAIN BOX: {objecti}"
    PlayerCountWidget : button_loud = button_loud{}

   
        UpdatePlayerlCount(Totalplayer : int):void=
            PlayerCountWidget.SetText(PlayerText(Totalplayer))

    
        CreateMyUI() : canvas =
            PlayerCountWidget.SetText(PlayerText(Objective))
            
            MyCanvas : canvas = canvas:
                    Slots := array:
                        W := canvas_slot:
                            Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.0}, Maximum := vector2{X := 0.5, Y := 0.0}}
                            Offsets := margin{Top := 400.0, Left := -700.0, Right := 0.0, Bottom := 0.0}
                            Alignment := vector2{X := 0.5, Y := 0.5}
                            SizeToContent := true
                            Widget := PlayerCountWidget
                       

            return MyCanvas

does it show for only1 player

yes

had the same issues, some1 else posted a solution I think. I found a soluation myself Idk wat it as but i thought like every time I created a new UI the widgets had to be unique and new instances too or some idk

Do you have a example of code where you fixed that problem ?

Someone told me i have to create a Button loud widget for each player but i dont know how to do

1 Like
W := canvas_slot:
    Widget := loud_button{} #so you will create a new button every time you call the function

thank you, but where do i put this ? what line do i put this in ?

can you try to put this line on my code so i can see if it work ?

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



# 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
objectif := class(creative_device):

    @editable
    Zonealte: mutator_zone_device = mutator_zone_device{}

    @editable
    zoneUI: mutator_zone_device = mutator_zone_device{}
    
    var  Objective : int = 0
    var Players : []player = array{}
    var MaybeMyUiPerPlayer : [player]?canvas = map{}
    

    OnBegin<override>()<suspends>:void=
        Zonealte.AgentEntersEvent.Subscribe(OnMutatorZoneEnter)
        Zonealte.AgentExitsEvent.Subscribe(OnMutatorZoneLeft)
        zoneUI.AgentEntersEvent.Subscribe(HandleButtonInteraction)
                
    
    HandleButtonInteraction(Agent : agent) : void =
        if (InPlayer := player[Agent], PlayerUI := GetPlayerUI[InPlayer]):
            if (MyUi := MaybeMyUiPerPlayer[InPlayer]?):
                PlayerUI.RemoveWidget(MyUi)
                if (set MaybeMyUiPerPlayer[InPlayer] = false) {}
            else :
                NewUI := CreateMyUI()
                PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.None})
                if (set MaybeMyUiPerPlayer[InPlayer] = option{NewUI}) {}



    OnMutatorZoneEnter(InAgent : agent):void=
        set Objective += 1
        UpdatePlayerlCount(Objective)
        Print("{Objective}")

    OnMutatorZoneLeft(InAgent : agent):void=
        set Objective -= 1
        Print("{Objective}")
        UpdatePlayerlCount(Objective)

    
    PlayerText<localizes>(objecti : int) : message = "PLAYER LEFT IN THE MAIN BOX: {objecti}"
    PlayerCountWidget : button_loud = button_loud{}

   
        UpdatePlayerlCount(Totalplayer : int):void=
            PlayerCountWidget.SetText(PlayerText(Totalplayer))

    
        CreateMyUI() : canvas =
            PlayerCountWidget.SetText(PlayerText(Objective))
            
            MyCanvas : canvas = canvas:
                    Slots := array:
                        W := canvas_slot:
                            Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.0}, Maximum := vector2{X := 0.5, Y := 0.0}}
                            Offsets := margin{Top := 400.0, Left := -700.0, Right := 0.0, Bottom := 0.0}
                            Alignment := vector2{X := 0.5, Y := 0.5}
                            SizeToContent := true
                            Widget := PlayerCountWidget
                       

            return MyCanvas

It’s not that simple here, because you’ll need to update the data, and therefore you need to append the array with a save to update the data later.

        CreateMyUI() : canvas =
            PlayerCountWidget.SetText(PlayerText(Objective))
            
            MyCanvas : canvas = canvas:
                    Slots := array:
                        W := canvas_slot:
                            Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.0}, Maximum := vector2{X := 0.5, Y := 0.0}}
                            Offsets := margin{Top := 400.0, Left := -700.0, Right := 0.0, Bottom := 0.0}
                            Alignment := vector2{X := 0.5, Y := 0.5}
                            SizeToContent := true
                            Widget := PlayerCountWidget #Briefly, the initialization is done here
                       

            return MyCanvas

It can be written better, but I don’t know how you have everything on the map. If the UI will be hung for the player only 1 time, then everything will be fine, if not, then you need to write completely different.

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



# 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
objectif := class(creative_device):

    @editable
    Zonealte: mutator_zone_device = mutator_zone_device{}

    @editable
    zoneUI: mutator_zone_device = mutator_zone_device{}
    
    var  Objective : int = 0
    var Players : []player = array{}
    var MaybeMyUiPerPlayer : [player]?canvas = map{}
    var Buttons : []button_loud = array{}
    

    OnBegin<override>()<suspends>:void=
        Zonealte.AgentEntersEvent.Subscribe(OnMutatorZoneEnter)
        Zonealte.AgentExitsEvent.Subscribe(OnMutatorZoneLeft)
        zoneUI.AgentEntersEvent.Subscribe(HandleButtonInteraction)
                
    
    HandleButtonInteraction(Agent : agent) : void =
        if (InPlayer := player[Agent], PlayerUI := GetPlayerUI[InPlayer]):
            if (MyUi := MaybeMyUiPerPlayer[InPlayer]?):
                PlayerUI.RemoveWidget(MyUi)
                if (set MaybeMyUiPerPlayer[InPlayer] = false) {}
            else :
                NewUI := CreateMyUI()
                PlayerUI.AddWidget(NewUI, player_ui_slot{InputMode := ui_input_mode.None})
                if (set MaybeMyUiPerPlayer[InPlayer] = option{NewUI}) {}



    OnMutatorZoneEnter(InAgent : agent):void=
        set Objective += 1
        UpdatePlayerlCount(Objective)
        Print("{Objective}")

    OnMutatorZoneLeft(InAgent : agent):void=
        set Objective -= 1
        Print("{Objective}")
        UpdatePlayerlCount(Objective)

    
    PlayerText<localizes>(objecti : int) : message = "PLAYER LEFT IN THE MAIN BOX: {objecti}"
    

   
        UpdatePlayerlCount(Totalplayer : int):void=
            for(B : Buttons):
                B.SetText(PlayerText(Objective))

    
        CreateMyUI() : canvas =
            PlayerCountWidget : button_loud = button_loud{}
            PlayerCountWidget.SetText(PlayerText(Objective))
            set Buttons += array{PlayerCountWidget}
            
            MyCanvas : canvas = canvas:
                    Slots := array:
                        W := canvas_slot:
                            Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.0}, Maximum := vector2{X := 0.5, Y := 0.0}}
                            Offsets := margin{Top := 400.0, Left := -700.0, Right := 0.0, Bottom := 0.0}
                            Alignment := vector2{X := 0.5, Y := 0.5}
                            SizeToContent := true
                            Widget := PlayerCountWidget
                       

            return MyCanvas
1 Like

IT WORK ! Thank you soooooooo much :heart: