Static variables can be very useful.
Real world example:
- On spawn actor it adds itself into static array of instances and on destroying it removes itself from that array.
In that way you always have array of instances of that class. - Singletone pattern. Create instance of some manager and assign it to static variable wich you can access from anywhere.
There is currently 2 ways i can implement static variable in blueprints:
- With functional library i can implement only static constant global variables not the one i can change at runtime.
- With making global variables inside of GameMode class i will make all blueprints to depend on that specific GameMode class and i loose modularity and cant create separate module what relyies on static variables.
This implementations are far from ideal (No modularity).
So which are the reasons for blueprint to not have static variable.
And are there any plans for adding such ability?
(It is possible to add static variables into Blueprint functional Library. Or better
make new blueprint type called “Static Blueprint” which will be able to contain static function variables and possibly events. That static blueprint will be presented as single instance.)