I am making a boss fight map and I am trying to make a player class so that the UI shows for every player but for whatever reason it shows the full UI for one player and doesn’t show the full UI for the other. Here is the code that I am using.
BossFight.txt (7.9 KB)
Hi, you’re using the same widgets for every players, meaning that whenever you call the GameUI.AddWidget(BossHPBarUI())
it will move the widget from the older player’s ui to the newer one, here :
CreateOverlay<private>() : overlay=
TheOverlay := overlay:
Slots := array:
overlay_slot:
Widget := BossBarColorBase # should create a copy
overlay_slot:
Widget := CreateTopHealthBar(1200.0)
overlay_slot:
Widget := HPBarTitleTextBlock # should create a copy
set Overlay = TheOverlay
As a general pratice, your BossHPBarUI()
function should take a Player: player
argument so that you can create a new UI for this player and store the reference to this “player UI” somewhere.
I think some other things might block you out, but I can’t figure it out yet… I feel like doing multiplayer Verse UI is not as easy as it should be somehow
In the code you sent, you have the same problem :
CreateOverlay<private>(CustomPlayer : player) : overlay=
TheOverlay := overlay:
Slots := array:
overlay_slot:
Widget := BossBarColorBase # not a copy
overlay_slot:
Widget := CreateTopHealthBar(1200.0)
overlay_slot:
Widget := HPBarTitleTextBlock # not a copy
set Overlay = TheOverlay
I don’t know if you understood what I was saying then, you can’t have a single HP bar for all your players, you need to give one to each players even if they are the same ones.
Yes I don’t fully know what your saying. I thought you meant to put Player : player inside the BossHPBarUI. Could you do what you had in mind for me and then send the code back to me?
CreateOverlay<private>(CustomPlayer : player) : overlay=
TheOverlay := overlay:
Slots := array:
overlay_slot:
Widget := MakeBossBarColor()
overlay_slot:
Widget := CreateTopHealthBar(1200.0)
overlay_slot:
Widget := MakeHPBarTitleTextBlock()
set Overlay = TheOverlay
MakeBossBarColor():color_block=
color_block{} # create a new one, don't use a global variable
MakeHPBarTitleTextBlock():text_block=
text_block{} # create a new one too
Calling {}
after a class calls a constructor
, which means you’re gonna create a new instance of that class, if you do so in a global variable (BossBarColorBase
) then you use it through your code, you’re using the same widget for everybody, which can’t work.
But as I was saying, maybe you have more errors so, maybe try this first
I am not sure I did this right, because it still doesn’t show the full UI for the second player. Could you just make the edits to my code for me then just send it back to me as a .txt file?
Sorry I don’t want to redo your whole script, but maybe try to understand what happens, also the image you sent is not good, you only uncommented my comments
Ok, well can you at least example a little bit better? I thought you were showing that I needed to add MakeBossBarColor():color_block= and other functions for the other UI elements.