[Blueprint] How to properly setup interface messages

I have recently come across a bug in the workings of a small test project: an interface message.

It seems to not want to work properly as every time the event “ReceiveActorBeingOverlap” occurs, the MG_Counter event doesn’t.

I suppose I’m missing how something works, and I suspect it’s the “Global” actor. Or whatever the target for the interface message function is supposed to be.

And yes, the blueprints, that each string of functions are in, are in the same implemented interface.

Hey Samuel,

Could you give us some more information about your interface and how you are implementing it, including screenshots of the full Blueprint window? Is the graph shown in screenshot 1 in its own Blueprint or in the Level Blueprint? Also, the Global target should be a Blueprint that also implements the interface that contains MG_Counter.

You can find more information on how to implement interfaces in the Blueprint Interface documentation as well.

Best Regards,

Ryan

Sorry Ryan,

It seems I misunderstood one of the uses of an interface message. I was thought that when the interface function “MG Counter” was executed, it would then trigger the “MG_Counter” event. And to answer one of your questions, none of the images are of the world blueprint and they’re all separate. I suppose I’ll have to figure out a way to cram an actor, HUD, and function together in one blueprint now? I don’t know.

Thanks.

Well whatever you want the event to do should be in the target. So when the function is called in the one Blueprint it will send the event to the target(s). If you move the event to the Global it should work fine, if that isn’t feasible you may have to move things around. The blueprints should go as follows:

  1. Blueprint Interface the function is declared
  2. Blueprint one calls the function its target being the BP that should know this function is being called
  3. Blueprint with the Event that defines what should happen. This would be the Global target you have wired up in the picture

Also currently in which blueprints are you calling the interface message and event? Let me know if you have any questions.

Best Regards,

Ryan

Alright here’s another question: how do you transfer a set variable from one blueprint to another? Say a string variable?

I know this is possible in C++ with friendships setting to public and other ways, but I can’t find a way to set friends nor does setting a variable to public work in the traditional sense.

Hi Sam,

Here is a “simple” step-by-step test that should demonstrate how to pass a string:

  1. Create an Actor BP (I’ll call it SENDER)
  2. Create another Actor BP (RECEIVER)
  3. Create the BluePrint Interface (BPI)
  4. In the BPI, add a function “Pass_String”
  5. Add new input string
  6. Add new output string
  7. In SENDER and RECEIVER “Blueprint Props” add the BPI
  8. In SENDER add a new variable> Object> Actor> Name it “Target_BP”
  9. Target_BP > Details > Check on Editable
  10. In SENDER add a new variable> string> name it “TEST_HELLO”
  11. TEST_HELLO > Details > Check on Editable
  12. In SENDER add Event Receive Begin Play
  13. Drag off the event to add a delay > Duration 2 (This is just so we can see what we are doing when we test it)
  14. Drag off the delay > Interface Message > BPI > Pass_String
  15. Get Target_BP > Plug into Pass_String target
  16. Get TEST_HELLO > Plug into Pass_String input
  17. Drag execute from PASS_STRING > Add Print String node
  18. Plug PASS_STRING output into Print String input
  19. Compile
  20. Go to Defaults > set TEST_HELLO to “Hello”
  21. Compile
  22. Save SENDER
  23. Open RECEIVER
  24. Open PASS_STRING function
  25. Drag the in string off Pass String > Add Append (This string currently holds the value “Hello”)
  26. In Append “B” input write " World" (put a space before World)
  27. Plug Append’s Return Value string into the return node
  28. Compile
  29. Save RECEIVER, SENDER and BPI (if any are not saved)
  30. Drag SENDER and RECEIVER from the content browser into the map
  31. In the scene outliner, select SENDER
  32. Details > Target BP > RECIEVER
  33. PIE

In two seconds, “Hello World” will be printed. I have attached images of the BluePrints for reference. Please let me know if this has helped you. I have informed our doc team that the Blueprint Interface page is a bit outdated. If you have any other questions about this, please feel free to ask.

Thank you,

Alexander

Unfortunately, this didn’t help. I think it’s because I tried setting the variable in the function, but I don’t know how else to do it while still following the guidelines.

I attached screens of what I did.

Is there somewhere else you assigned value to Target_BI? The target pin for the interface message needs to be wired to a reference to your HUD blueprint. You will need to make sure that something is going out of your return in “scoringThing” since NewParam1 going into your PrintString empty currently. Also, what is executing your draw text? You will probably want an On Tick event to drive that. Please let me know if this has helped to resolve the issue.

Thank you,

Alexander

I didn’t assign a value to Target_BI.

“The target pin for the interface message needs to be wired to a reference to your HUD blueprint.” I can reference other blueprints in a blueprint that’s not the world blueprint?

“You will need to make sure that something is going out of your return in “scoringThing” since NewParam1 going into your PrintString empty currently.” I just did without everything that calculated the score and just gave it a string with a default setting. Still did nothing.

And the draw text execution, I already fixed that. I realized that particular error shortly after I sent the screenshots.

Well, it still didn’t work correctly, and I’m having my doubts that interface messages are actually made for the purpose I’m wanting to use them for. That purpose being blueprints sharing data with each other.

After burying the idea of ever using interface messages, I used a system of Event ReceiveActorBeginOverlap to transmit data to and fro’ blueprints. It works surprisingly well. Though it’s limited to single bits and a large amount of ticks, it gets the job done. However, I ran into a problem…

It seems as if the HUD function “Draw Text” can only be executed by the Event ReceiveDrawHUD or things also executed by said event. So the “Draw Text” function can’t be updated more than once and the suggestion to use the tick event doesn’t update it either… Is this program purposely fighting me?

Regardless, is there a way to trigger the Event ReceiveDrawHUD on command, make other events work, or another way to put dynamic text (besides the “Draw Text” function) on the HUD?

Thanks for putting up with me so far,
Sam.

P.S. I’m willing to accept no answers at all after this comment as my last questions don’t pertain much to interface messages. Though I would appreciate any answers/help.

Hi Samuel,

You are correct that interfaces are used for sharing data and execution flow between Blueprints. As long as the target pin on the interface message node is connected to a reference to a Blueprint that implements the interface, the function or event in the target will be activated.

In order to get your HUD reference in your “Sender” Blueprint you will need to add a “Get Player Controller” node via the right-click menu. From the “Get Player Controller” node’s Return Value drag off and create a “Get HUD” node, then use the “Get HUD” Return Value as the Target for your BPI. Here is what it would look like:

What I had said about On Tick was incorrect, I apologize. Displaying your Draw Text on your HUD should be done with the Event Receive Draw HUD. Then use Draw Text from that to create your display. The text color by default is Alpha 0 (transparent), so please make sure the input color is visible. You HUD should automatically update with any changes to the string variable.

hud.png

Please let me know if there is anything else that is not functioning as expected.