Question about custom UI (Like health bar)

I’m trying to create a Health bar in a multiplayer game and AddWidget to all clients’ screens. However, after my struggle, I found that I couldn’t use a variable to store the Widget information and AddWidget to all players. I had to create a Widget variable for each player and track those variables to constantly update them and the player’s UI. I had to use a map{ player, widget } to store this data.

But this raises several questions. First of all, this map will become larger as the number of players increases. For example, things like the boss’s health bar will be displayed on all players’ screens at the same time. It is unreasonable for each player to save a copy of the data. When I update this UI data and update the player’s UI, I need to iterate this map, first remove their current Widget, update the Widget data, and then add the Widget to the screen. The higher the number of players, the slower this process will be. There will be situations where the Widget update is not timely. Then I thought that I might be able to use spawn expression to let them update concurrently. This might work, but unfortunately, I don’t have enough people to participate in the test, so I don’t know if this will work with more people.

Secondly, my method induced a bug that I couldn’t fix. I thought it might be a thread safety issue. Like the Health Bar update, which can come from multiple places, not just damage caused by players. If multiple places want to update the UI at the same time, it may result in simultaneous access and modification of the map variable mentioned above. The result is that players can see multiple layers of Health Bar widgets stacked on top of each other.

I think Verse should provide an interface to load the same Widget on all player screens (using only one variable). In addition, I would like to ask how everyone solves the UI problem when they encounter such an issue.