List ways of Calling variables from other Blueprints?

I know this has been answered lot of times all over the internet.

But I still got to ask as I am not able to wrap my head around it about which is the better way.

I guess there is no one perfect way. It depends on our situation right?

So how do we actually decide depending on situation.

Let’s say I have a camera BP and I want it to adjust its position depending on the grid size from another Grid generating BP.

I can provide the values directly in camera BP. But my grid size might change depending on user input and I want camera location to adjust accordingly to fit the grid in the screen only on “Event Begin Play”. So I need to reference variables from Grid BP to camera BP.

I have only two ideas as seen in above image. There might be many more out there, Then I wanna know please.

I cannot totally understand from above two. How to decide which to use?

Also I always struggle what object to put in into cast node. I mean I know it just checks the input object and if it is correct it gives output. But how some peoples uses it to reference variables and what they put into input object node?

Because casting fails if we don’t provide input object node to it.

In above answered link he suggested three ways. I didn’t understand the second one though!
Also documentation link from 2nd answer is dead. So can’t find good documentation just related to referencing variables.

Then

Here is another. See the 2nd last comment by making it public.

Can anybody explain is it different from the three method suggested in previous link?

How to do it? Because he say right click and variable will directly appear in other BP. Doesn’t seem to work.

Also I seen people using event dispatcher to communicate and its also on Unreal Engine youtube playlist.

But it seems inappropriate to create event dispatcher just to pass a variables. Or Not?

So which way to prefer depending on different situation?

Can Anybody list advantage and disadvantage of using one way over the other? Or

Is there some video tutorial / documentation link which will resolve all these confusions I am having?

Note that I am more interested in clearing these confusing than solving my Camera BP issue. I can solve that issue by “Get Actor of class” I am just interested in various ways of referencing variables.

From your description, what you actually need, is a shared data resource.

In many cases, and yours, that would be the game instance. There’s no need for objects to be talking to each other, when they can share a common data pool.

Having said that, I will answer the other stuff.

GetActorOfClass is for when the object is in the world, but you don’t have a reference already.

Casting ( a very misunderstood subject ), is NOT for talking between blueprints. The purpose of casting, is to ‘reinterpret’ the type of an object. It changes object type A into object type B, WHEN B is a descendant class of A. Then, maybe, yes, you can communicate, but casting is not for communication.

If you’re looking for good models for running communication between hex blocks and a camera, then game instance, with the possible addition of event handlers would be a good starting point. But it still does depend on how you’re set things up. [ Is each hex a BP, or are all hexes on BP, or are they inanimate objects controlled by the level BP? etc… ]

Thabks for this explaination.
There are two BP. HexMeshBP and HexGridBP. HexgridBP simply spawns HexMeshBP several times in grid manner.

Also I haven’t used a event handler before.

So with quick search I found this

It seems difficult for beginner like me. Although I will read it again and again.

Is this should I begin with or is there any beginners friendly tutorial out there that I can learn from about event handler?

I only talked about event handlers because they are a way of talking to many objects with one call. You may or may not need them. This guy’s tuuts are always useful:

I think the main thing for you might be the game instance, because you hex units and the camera can communicate that way. They can leave data for each other, and pick it up every now and then. The game instance is sort of data only ( variables ) blueprint that everything can see, and lives for your whole game, even between levels:

Thanks …although I am still unaware about game instance as this is my first project. But thanks for the tips with this much info I am starting to get the basic idea about it