How to communicate between two widgets
I'm trying to get two widgets to talk to each other by using an OnClicked event.
Basically what I want to do is, *Click a button in widget A *Set a bool in widget A to true *Click a button in Widget B to call the Widget A bool to create another widget.
My problem is, I keep getting accessed none errors, I've tried every method I know. But I haven't had any luck. I've been able to communicate between a BP_Actor and a Widget before using Custom Events, but it won't work when I try it with two widgets. I'm also not able to set a value for the Widget A variable in Widget B like the documentation said to do.
Any help would be greatly appreciated.
Here are some screenshots: Widget A: https://gyazo.com/c07c683a6a51a61d5d4f7e1f985e9813 Widget B: https://gyazo.com/ed0c6d3b97f9504e6ada756a86b15c6c
asked Jun 22 '16 at 04:55 AM in Blueprint Scripting
Kinda depends what you've attached these widgets to, but let's say the Parent here is your player controller (easiest example). One thing that should work is to go back in your controller blueprint and find wherever you've created those widgets in the first place before adding them to the viewport. The create nodes should have a blue output pins on them - right click each and Promote to Variable. Give them names that make sense to you, like "WidgetA" and "WidgetB" in your case. That will save a reference to each that will be important later when you try to communicate between them.
So in Widget A, you can get the owner - which will likely be a generic controller - then Cast To your special type of controller - and then the reference to Widget B can be pulled off that cast node. You can then change a variable or toss an event into B as you wish. If you are doing this in some sort of pawn or character, you might need an extra step to get the controller - then get that thing's "controlled pawn" - cast that to your BP_Actor class and look up your widget references there.
Note that things are cleaner here in 4.12 - if you're still in 4.11 or earlier there's even one more step. Once you have the widget reference to Widget B, you used to have to pull off that and get the user widget object, then Cast To whatever widget type that guy is, and -then- you can get into its variables and events. Way confusing and always seems to take more nodes than it should. If you're blindly trying to find the magic node that does all that, you'd never find it on your own.
answered Jun 22 '16 at 05:15 AM
One easy way to do this is make one widget create the other widget. So for example Button A widget does a "create widget" for Button B. Then Button A adds itself to a variable in Button B and at the same time Button A adds a variable to Button B. You can easily do this off an Event Construct.
answered Jun 22 '16 at 05:03 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here