I made a interaction system where when you click on a box it increases a integer by 1. This works but it only adds it to its instance of the box. I need to figure out how to make it all one number. Everything else works as intended.
The most obvious way would be to declare the integer variable as static, but afaik, those are not supported in Blueprints. You would have to make a C++ base class for the Blueprint to create it.
Some more blueprint-friendly ways would be to create your own GameInstance blueprint class, declare the integer there, and set it as the default GameInstance class in the project settings.
I double down on this approach, with a map type variable of <Class, Int>. So that you could have one distinct integer for each class.
Even better, you define an interface with methods GetClassValue(Class) → int, SetClassValue(Class, int). Then you implement this interface on whatever “global” object you want, such as the GameInstance
an instance definitely holds its own variables…
if the integer is an independent score,you shouldn’t put it in the box.
you can make something else to hold the score,can be an empty actor or character or game mode.
when interacting with the box you can get the score manager,and modify the only one integer.