Blueprint Communication

Hello. I 've got a blueprint communication problem. It 's simple I guess but I 'm totally stuck. I want a laser to block the opening of a door. If I block the laser the door will open, if not it will close again. I tried Begin/End overlap but they run in the same time(?) (Screenshot 1 and 2)
I gave up on overlaps because I use tick for laser beam, I guess something’s wrong with it.
I moved to Blueprint Interface.(Screenshot 3 and 4).

So we have a laser and cube which work perfect and I need the laser to communicate with the door.

If the hit actor of the line trace is the cube simply call events Open/Close door. But how am I gonna get a reference to the door so I can plug it into the target ?
Should I create a BP which collides with the EndPoint of the beam and check if it 's not colliding then open the door?

][3]

If I understand the problem correctly, you are trying to get a reference to another actor in a level.

There are multiple ways to go about this. The simplest method that meets your current requirements, may be to give the door a tag like “Cube01” and from the cube call the “GetAllActorsOfClassWithTag” node using your Door class and “Cube01” as your respective parameters.

The simplest method that meets your
current requirements

The simplest one is to drag and drop into the level blueprint, for sure.

I’d make something like:

  1. create the laser blueprint that updates on tick (you don’t really need every frame, I guess 5-10 times a second will be more than enough). This blueprint uses a line trace that hits its own receiver component, which may be a mesh or an invisible collision box, whatever works for you.

  2. Now simply check in a hit actor is self or something else. If it’s not self, then something is blocking the laser. Here you can adjust the laser end point for visual representation.

  3. In the laser BP, create a variable of type Actor, make it public. When you place the laser actor into the level, select your door as the variable value.

  4. Ideally I’d implement an interface to send interface calls, because you’ll be able to use it for not just doors. So when laser is blocked, you send an “open” call to your actors. When it’s not blocked, send a “close” call (or not, if you don’t need to close them back).

  5. Surely you don’t want to make interface calls on tick, so just add a DoOnce nodes before making interface calls, and you can reset them whenever the opposite call is made.

  1. Ideally I’d implement an interface to send interface calls, because you’ll be able to use it for not just doors. So when laser is blocked, you send an “open” call to your actors. When it’s not blocked, send a “close” call (or not, if you don’t need to close them back).
  2. Surely you don’t want to make interface calls on tick, so just add a DoOnce nodes before making interface calls, and you can reset them whenever the opposite call is made.

These are actually my 3 and 4 screenshot.

Can you explain this?
3) In the laser BP, create a variable of type Actor, make it public. When you place the laser actor into the level, select your door as the variable value.

When you create a variable in any blueprint, there’s a small icon of an eye next to it. If you press it and the eye is open, you’ll be able to individually set this variable for any instance of your blueprint placed into the level.

Thanks for your help it 's working now. I did with do once and reset things and it 's all good. (Screenshot 1).One more way to do this is that I set the Actor variable as the door in level blueprint in begin play and that works too(Screenshot 2). I 'll check the best solution when it 's time. Have a nice day

335370-2.png

Variables have another checkbox called “Expose on Spawn”. If you check it, the variable will be available on the Spawn Node after you select a respective blueprint class.

Just one more question which I don’t really mind. What if I dont place the laser in world and I want it to spawn through a trigger box? In that case I cannot set the actor as door as in screenshot.

335371-download.png