I’m trying to use Verse to create a loadout selector on game start. To create the UI, I’m using a Canvas. The Canvas part looks something like this:
Omitted the canvas styling but it works and appears on the screen.
NewCanvas : canvas = canvas:
Slots := array:
canvas_slot:
Widget := TitleBlock
# Assault
canvas_slot:
Widget := AssaultBlock
canvas_slot:
Widget := AssaultButton
The widgets are defined above the code and look like this:
AssaultButton : button_regular = button_regular{DefaultText := TextForAssault}
AssaultButton.OnClick().Subscribe(AssaultPressed)
I create the UI here:
HandleButtonPress( gamer : agent) : void =
if (Player := player[gamer], PlayerUI := GetPlayerUI[Player]):
set PlayerCanvas = CreateUI()
PlayerUI.AddWidget(PlayerCanvas, player_ui_slot{InputMode := ui_input_mode.All})
The function that’s called is like this:
AssaultPressed (Message : widget_message) : void =
Player := Message.Player
if (PlayerUI := GetPlayerUI[Player]):
PlayerUI.RemoveWidget(PlayerCanvas)
AssaultGranter.GrantItem(Player)
if (FortniteCharacter : fort_character = Player.GetFortCharacter[]):
FortniteCharacter.SetMaxShield(100.0)
In the actual code, there are other duplicate methods for the other classes. This method works perfectly fine in Live Sessions with just me. The problem arises when I invite a friend to join the Live session through Creative. When they are in the game, the UI doesn’t disappear for me (it works fine for them) even though the buttons still activate the item granters and change my inventory. This traps me in the screen and I cannot move unless I force respawn, in which case I lose my crosshair and ability to open the inventory. What is happening here?
Another problem with this code is that the SetMaxShield doesn’t persist after I die (it goes back to 100 for all classes). How can I make that max shield change permanent?
Please let me know what I’m doing wrong. Also, if there are any places I can find better resources; currently I’m using Verse API Reference and the .digest.verse files in VSCode.