I’ve been testing the new variable functionality in Blueprint widgets and created a basic scoreboard to display and manipulate through Verse. However, I’m having a problem: when I try to show it to all players on the map, it only appears to the last player who ran addwiget, and it disappears completely for the player who had it before them. Is there a way to make the widget appear to all players simultaneously without creating a new widget in Verse, instead using the one from the graphical interface, as shown in the attached screenshots?
osea preguntaba si nesecitaba hacer algo extra para que sea funcional, pero estoy intentando y me esta dando este error.
es cuando intento agregar la carpeta en:
UI_V:= module: # UI Folder name in content browser - Change for your main ui folder and any sub folders
AwaitingPlayers<public>:=module{} # Sub folder
AnimatedLikeUI<public>:=module{} # Sub folder
MapCode<public>:=module{} # Sub folder
Ui_Widget<public>:=module{}
If you use what i shared then remove any ref to my data and replace with your own. Im sorry i cannot understand some things. You could also place the var WIdgetName :widget = widget{} inside the for() in your function it should work the same
I’m trying to add my folder in the modules section, but I’m getting the error I showed above, saying it’s ambiguous, as if it were duplicated, which it isn’t.
The problem is that when I add it, I get an error, and I don’t understand why I need to give the folders special permissions. From what I understand, the modules are the folders in my content box, but when I enter any folder name, I get an error, and that’s what I don’t understand. In fact, I didn’t get an error with yours, and I don’t have any folders with that name.
It’s already showing up for everyone, but I have a problem: I can’t use (UIScore) because if I use it, it only shows up for one player. But if I add Ui_Widget.UI_RVB{}, then everyone sees it, but I can’t manipulate it the same way as (UIScore). Do you have any suggestions on how to manipulate it through the verse?
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }
WidgetType := enum:
# Add widget types here
ScoreBoard
CustomWidget := enum:
Add
Remove
#UI_V<public>:= module: # UI Folder name in content browser - Change for your main ui folder and any sub folders
#Ui_Widget<public>:=module{}
ScoreBoard_UI_RVB := class(creative_device):
@editable
TeamRScoreManager : score_manager_device = score_manager_device{}
@editable
TeamBScoreManager : score_manager_device = score_manager_device{}
@editable
ElimRed : elimination_manager_device = elimination_manager_device{}
@editable
ElimBlue : elimination_manager_device = elimination_manager_device{}
var UIScore : Ui_Widget.UI_RVB = Ui_Widget.UI_RVB{}
FormatScoreTR<localizes>(Score : int) : message = "{Score}"
FormatScoreTB<localizes>(Score : int) : message = "{Score}"
TeamRedText<localizes> : message = "Team Red"
TeamBlueText<localizes> : message = "Team Blue"
var PlayerWidgetMap : [player][WidgetType]widget = map{}
#################### Examples ####################
# Single Player
# Add -> UpdateWidgetForPlayer(Player, WidgetType.AwaitingPlayers, CustomWidget.Add)
# Remove -> UpdateWidgetForPlayer(Player, WidgetType.AwaitingPlayers, CustomWidget.Remove)
# All Players
# Add
# AllPlayers := GetPlayspace().GetPlayers()
# UpdateWidgetForAllPlayers(AllPlayers, WidgetType.LikeAndFav, CustomWidget.Add)
# Remove
# AllPlayers := GetPlayspace().GetPlayers()
# UpdateWidgetForAllPlayers(AllPlayers, WidgetType.LikeAndFav, CustomWidget.Remove)
# Get widget for input player
# PlayerWidget := GetWidget(Player, Type)
# Remove all widgets for input player
# RemoveAllWidgets(Player)
# Get all widgets for input player
# AllPlayerWidgets := GetAllWidgets(Player)
OnBegin<override>()<suspends>:void=
set UIScore.TRed = TeamRedText
set UIScore.TBlue = TeamBlueText
set UIScore.TRPuntos = 0
set UIScore.TBPuntos = 0
GetPlayspace().PlayerAddedEvent().Subscribe(ShowUI)
ElimRed.EliminationEvent.Subscribe(TeamRedElim)
ElimBlue.EliminationEvent.Subscribe(TeamBlueElim)
AllPlayers := GetPlayspace().GetPlayers()
UpdateWidgetForAllPlayers(AllPlayers, WidgetType.ScoreBoard, CustomWidget.Add)
ShowUI(Player:player):void =
AllPlayers := GetPlayspace().GetPlayers()
UpdateWidgetForAllPlayers(AllPlayers, WidgetType.ScoreBoard, CustomWidget.Add)
UpdateWidgetForPlayer(Player:player, Type:WidgetType, Status:CustomWidget):void=
# Does the action for the input player
Widget := GetWidget(Type) # Creates an instance of the widget
case(Status):
CustomWidget.Add => AddWidgetToPlayer(Player, Type, Widget)
CustomWidget.Remove => RemoveWidget(Player, Type)
UpdateWidgetForAllPlayers(PlayerArray:[]player, Type:WidgetType, Status:CustomWidget):void=
# Does the action for all players in the input array
for(Player :PlayerArray):
Widget := GetWidget(Type) # Creates an instance of the widget
case(Status):
CustomWidget.Add => AddWidgetToPlayer(Player, Type, Widget)
CustomWidget.Remove => RemoveWidget(Player, Type)
GetWidget(Type:WidgetType):widget=
# Returns an instance of the widget
case(Type):
WidgetType.ScoreBoard => Ui_Widget.UI_RVB{} # Ref the widget in the directory in the assets digest. I use my sub modules as above
# Add a widget for the input player
AddWidgetToPlayer(Player:player, Type:WidgetType, Widget:widget):void=
if(PlayerUI := GetPlayerUI[Player]):
PlayerUI.AddWidget(Widget) # Adds the widget to the screen
var WidgetMap : [WidgetType]widget = map{}
if(ExistingMap := PlayerWidgetMap[Player]):
set WidgetMap = ExistingMap # Copies the current map
if(set WidgetMap[Type] = Widget):
if(set PlayerWidgetMap[Player] = WidgetMap){} # Sets new map to current + new widget
# Removes a single widget of the specified type from input player's UI and the map
RemoveWidget(Player:player, Type:WidgetType):void=
if(WidgetMap := PlayerWidgetMap[Player]):
if(Widget := WidgetMap[Type]): # Get the specific widget for the type if it exists
if(PlayerUI := GetPlayerUI[Player]):
PlayerUI.RemoveWidget(Widget)
# Create a new map without the removed widget
var NewMap :[WidgetType]widget = map{}
for(Key -> Value :WidgetMap, Key <> Type):
if(set NewMap[Key] = Value){}
# Reassign the updated map back to the player map
if(set PlayerWidgetMap[Player] = NewMap){}
# Removes all widgets for input player
RemoveAllWidgets(Player:player):void=
if(WidgetMap := PlayerWidgetMap[Player]):
for(Type -> Widget : WidgetMap): # Remove each widget one by one by type
RemoveWidget(Player, Type)
# Get a single widget for input player using the WidgetType if its valid
GetWidget(Player:player, Type:WidgetType):?widget=
if(WidgetMap := PlayerWidgetMap[Player], FoundWidget := WidgetMap[Type]):
option{FoundWidget}
else:
false
# Get all widgets for input player if valid
GetAllWidgets(Player:player):[WidgetType]widget=
if(WidgetMap := PlayerWidgetMap[Player]):
WidgetMap
else:
map{}
UpdateHUD(Player:player) : void =
if:
PlayerUI := GetPlayerUI[Player]
then:
for (Players : GetPlayspace().GetPlayers()):
ShowUI(Player)
TeamRedElim(Agent:?agent):void=
if:
RAgent := Agent?
Player := player[RAgent]
then:
TeamRScoreManager.Activate(Player)
set UIScore.TRPuntos = TeamRScoreManager.GetCurrentScore(Player)
UpdateHUD(Player)
TeamBlueElim(Agent:?agent):void=
if:
RAgent := Agent?
Player := player[RAgent]
then:
TeamBScoreManager.Activate(Player)
set UIScore.TBPuntos = TeamBScoreManager.GetCurrentScore(Player)
UpdateHUD(Player)
You can use the new verse bindings in the widget. Then when it does
Widget := GetWidget(Type) # Creates an instance of the widget
You should be able to access the values ie Widget.VerseScoreValue - This would be the verse binding inside the widget bp itself.
You could write a quick think to set the Widget.VerseScoreValue = NewValue i assume itll auto update so you wont have to show the playerui again.
This will help
Its still pretty new tbh i only created that device for a simple thing. If i ever need to have data inside a widget per player i will update it but in the meantime try what i said and check out the link to show the basics.
I will have a test tomorrow for you. I showed a simple widget without data to all players it even played animation ect. I haven’t gotten around to setting up var yet through the widget bp and verse.