I have simple widget to show number of items. I add it to player blueprint
It’s called by other actors
To add or remove 1 point.
And it’s working good except after I click ESC and return to editor I am getting lots of errors
is BP_ball is your player character?
Seems like the UI is already destroyed when you call the BoxPaintedBy* events. Just check the UI for validity before setting the points.
If these points represent something like score then you should probably consider storing them in the GameState instead. Your UI should ideally not contain any game logic.
Yes
UI store logic to do +1 or -1 to items displayed in UI. Maybe you have some good guides or tutorials about GameState and its interactions with UI?
Essentially, this blueprint needs to know what UI is. Creating a ref variable but not assigning a value achieves little. Imagine you have a string variable but forgot to type in the text. You have a variable that could hold text but is empty.
Similar to your UI var at the moment. It could refer to a widget, but which one? What if there are 4 UI widgets. Even if there is only 1, you must still assign value to the variable. That’s what the first pic does.
What you originally posted is quite confusing, actually. Especially that you say that it does work but throws errors…
Perhaps you could explain what the most important part of this thing is. The UI -> Set Points int what is it and how is it supposed to work? Judging by the cutoff W in the bottom right corner, we’re already inside some widget.
Perhaps you think:
These 2 are somehow related? Because they are not. Are you trying to push in Points value into the widget “I add it to player blueprint created in the player BP” in the very 1st pic you posted the thread?
And you are 100% correct. It fixed the issue. Thank you! Maybe you could also suggest some good tutorials about widgets and best practices in general? Thank you very much!
You’d need to be more specific. There’s too much stuff out there! The two things that come to mind: