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
I have simple widget to show number of items. I add it to player blueprint
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?
The errors point here:
You’re accessing a widget that has yet to exist, no longer exists or is not referenced properly. Think of how & when you set that UI
reference. It’s not shown in your screenshots.
I set it in my player blueprint (BP_Ball is my player).
And when I want to call a method of my UI I call it using my bp_ball
Not sure what you mean.
The errors complain about this specifically. You never show where it was set.
I am sorry I just got confused. I thought that set practically meant this:
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?
I think I know what you’re doing. You’re overthinking it:
Delete this part, and get rid of that UI variable. You already have the bits you need and this part is not necessary.
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:
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.