Access Variables in another BP

Hello i have a question about variables.
In my Main BP i set some variables:

My qustion is why can i access the variables like “Start Laser” and "Start X-Movement in another BP but not the DT_Laser variable?

Don’t make the Level Blueprint the main BP unless it’s level specific. The DT_Laser is a variable belonging to the Level Blueprint, actors can’t (easily) access it.

I tried makeing another BP for the logic but in Actor BPs i couldnt relate to multiple Actors that i want to move. Thats why i made it in the Level BP. What would be the alternative?

Impossible to tell without knowing what you’re doing. You choose tools / methods / comms according to what is needed.

If you’re going to have 1 level only, LB is fine and can be super useful. How to organise it all depends on the circumstances.

Im moving a laser with this logic:


Tahts why i used the Level BP bc i can refrence the moving parts here. I delayed the timeline to match the speed to the travelled distance.
In another BP where i spawn the laserbeam itself i turn it on and off with data from the same DataTable i used to move it. Initially i just used the same timeline to iterate through the datatable rows but now that i delayed the timeline the laser doesnt turn on and off at the right times anymore. Thats why i want to use the DT_Laser variable from the Main BP in the other BP i spawn the laser, to turn it on or off at the right times.

My problem is i cant use the actors in the BP i spawn the laser.

And I’d immediately question this approach. Why? Why not build this logic inside an actor? That’s what actors are for, and that’s what LB is not good at.

If you’re building a big complex machine with a lot of moving parts - this machine should be an actor. And the smaller bits of machinery modules could be components or even other actors. This way you end up with a self-contained entity that needs to rely on external data only when needed. And the internal comms are trivial to pull off.

Now, of you have multiple complex machines that need to talk to one another and exchange data, you can use the LB to facilitate the communication. But the LB should not contain logic that is unique to an actor. The LB does not need to know how each machine actor operates - this should be contained in the machine actor itself.


Thats why i want to use the DT_Laser variable from the Main BP in the other BP i spawn the laser, to turn it on or off at the right times.

You can have the LB update actors easily like so, sending them data:

However, having actors pull data out of the LB is like pulling teeth. Not so nice.

  • if you have an actor that does something and send some data:

image

  • and another actor that is waiting for that data:

image

  • the LB can help creating a link between them:

From now on those actors can communicate; the best part is that they do not reference one another. And this data can be sent to any actor that listens to the dispatcher, including the LB.


At a glance, this:

should be inside the machine actor. And if this machine does something, the LB can communicate it to another machine. Although this kind of communication can be done without the LB whatsoever, too.

1 Like

Ok thank you im gonna try to implement this into my game. But did i get it right, that i can only refrence one actor at a time in a Actor BP?

No, you can reference pretty much anything, pretty much anywhere. But even though you can, does not mean that you should.

one actor at a time in a Actor BP?

Nothing stops you from having multiple references to multiple or the same actor inside any BP.

But how can i do this? When i want to refrence something in the Main Level BP i can just drag and drop it fom the Outliner but that doesnt work in Actor BPs.

1 Like
  • i have 2 unrelated actor BPs, their instances are sitting in the level:

image

  • actor B has a new variable that can reference an instance of actor A:

  • actor B can now decide which instance of actor A to reference:

and B can now access A directly:

We’re not using the LB at all here.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.