So I have different levels in my game and I want to show player’s success rate when they hover over the level icon, in the main menu. If I was using the same Game Mode for main menu and the level, I could just get the variable of success rate, but they are using different game modes.
So, I created a score variable in widget class of the level. Then I added an event dispatcher at the end of the level, before it goes back to main menu. Then I created a widget reference in game mode of the level. After that I got a reference of the game mode in game instance. In game instance, I called the reference of game mode, and from that reference of the widget. I created a custom event that would update the score, if it is higher than previous level score, and binded it to event dispatcher in widget blueprint.
Then I created a timer by event to give me the level score every ten seconds. And it doesn’t work. It is stuck at 0. My in-game score variable in widget blueprint updates correctly, but I can not assign it’s value to the best score variable in game instance.
Sorry if I couldn’t explain myself more clearly. I am a beginner and I am not quite sure on what I am doing.
Ops, I came a bit late. I managed to solve the problem with exactly what you said. I tried to create the variable in level, and move that variable between levels but simply creating the variable in game instance solved the problem.
Still not sure why event dispatcher didn’t work though I made everything the right way