No announcement yet.

Communicating between blueprints

  • Filter
  • Time
  • Show
Clear All
new posts

    Communicating between blueprints

    I have two blueprints that I am having a hard time getting to communicate with each other.

    Laser Emitter Blueprint:
    Setup to emit a laser particle that bounces off certain surfaces, collides with others, or just keeps going until it reaches a certain endpoint (that all works fine). I am trying to now set it up to know when it hits a sensor. Once the sensor is hit then I would like for a light to come on.

    Sensor Blueprint:
    I just have a simple prototype right now. A cube with a point light hovering above it. The cube is what the laser will hit and then the point light will turn on.

    Currently I have the following setup:

    1) No script in the Sensor BP
    2) In the Laser BP, I have a function called "Toggle Sensor" (picture attached)
    3) That function is then called in the "Hit" function of Laser BP (picture attached)
    *the only way the Toggle Sensor function is called is if the particle successfully hits the sensor actor. (I used a break hit result from a line trace for this)

    When I run a simulation, the functions successfully fire, but the light visibility does not change. Can someone let me know what I am doing wrong?

    I'm kind of new to blueprints myself but try dragging off the "as bp sensor" and select the toggle sensor event from there. Your event needs the reference to what it is "targeting".


      Originally posted by RAMDAC View Post
      I'm kind of new to blueprints myself but try dragging off the "as bp sensor" and select the toggle sensor event from there. Your event needs the reference to what it is "targeting".
      Thanks for the response Ramdac, I am fairly new as well. I did try what you mentioned but the light still does not turn on.


        I don't know the details of the rest of your code, but it should be along the following lines:

        Your laser casts a line trace and then saves the hit light switch actor as a variable.

        You then cast to the actor of that class, as the saved variable actor(goes into the pin on the left side of the cast to node)

        From the cast to node, you pull off the "as bp sensor" pin(right side of node) and pipe that into your function.

        Casting can be weird to get used to at first, but it makes sense once you get the hang of it. To cast, you need to know which specific actor you want to cast to. There could be 1000 sensor actors and you want number 732 to be the one you toggle. This means that you need to have a means of selecting the correct actor in which you need to talk to.


          either it is something that IronicParadox says or your light component is turned off by default and according to piece of script you showed it never toggles the light on, because of Set Visibility's New Visibility is always set to False(unchecked). Try to use some Flip Flop node in between...maybe the problem is that simple. *Shrugs* (I mean the event is called Toggle Sensor, but it doesnt toggle, it just sets the same value over and over again)


            Thanks for the responses IronicParadox and Yaroslav. I went back and made some changes to my code. They issue still occurs but I just simplified the code a little. I attached screenshots of it. The screenshots showed up out of order but im sure you might understand which order they should be in lol
            Attached Files


              Drag off of WhileLoop's Completed and Set Beam Continue value to True...needs to reset values otherwise laser won't shot next time unless you reset it in some other script. And reset Limit Bounce as well here.

              After you're checking if Limit Bounce > 0, drag off of False pin of Branch node and add Set Beam Continue node(set value to False). You actually have it connected, you can keep the connection unless it will have issue with complex version of script. Then, remove any connections from True pin of Branch node, cuz you want to go back to While Loop's begin immediately with updated BeamStartPoint and BeamDirection.

              The node you got there, Set Beam Continue to False, which you have after you check if material is Mirror_M. Drag off of its exe pin and just go to cast to BP_Sensor. Drag off of its As BP Sensor and connect to Sensor to Affect (or add Set Target Sensor node and store it there if you really want to store it there and connect it to Toggle Sensor).

              In Toggle Sensor function drag off of Point Light and add Toggle Visibility node instead of Set Visibility.

              That's how I done it. The only thing is if you really want to Toggle light only when the laser bounces off at least one object or it's okay if the first hit object was the Sensor. Probably want to check if Limit Bounces = Max Bounces, to not allow to toggle light on first hit.

              Long story short: Beam Continue is what ruined it all for you.


                Thank you very much Yaroslav! That fixed the issue. I was worried that Beam Continue would be an issue when I added it. Thanks for taking the time to look over the code and give a solution!