In Java you could set in a class a static object/variable which could be accessed at any time from anywhere, useful in some instances where it doesn’t use a lot of memory, it doesn’t contain sensible security information, but it is used a lot during the “life” of that program, so you don’t have to keep saving and reading it from a file constantly. Here in Unreal Engine the class would be the blueprint. Can you do something similar? Let say I have something in my game that I want to be accessible any time I need to (read the values, change the values), and knowing that I would only need one instance of that object/variable.
So let’s say in a blueprint I’m creating an object that I want to be able to access it’s value and be able to change it in any other blueprint (level, widget…).
Let say I have something in my game
that I want to be accessible any time
I need to (read the values, change the
values), and knowing that I would only
need one instance of that
object/variable.
You could have the [Game Instance][1] (a persistent framework class accessible from anywhere) fetch and store a reference:
Now, any entity can reach out to the game instance and get that reference. Or they call the above themselves.
Apart from that, there are too many ways to properly reference stuff and have objects communicate. It really depends on what’s needed and each method (direct, dispatcher, interface) is circumstantial.
If you’re making an ArchVis project, care little about scripting and just want to access the Sun actor in the world, or the Menu Actor, the above might suffice.
But perhaps you could just use the existing actors - Game Instance, Game Mode, Player Controller. In many cases there’s only one, and any blueprint can access them at any time. And you can use an Interface to avoid casting.