How to use dispatcher between BPs

Hi, I’m working on a simple card game and I am new to UE4. I’ve been able to solve every problem I’ve run into so far, but I haven’t found help with this and It’s killing me.
So, I have a Deck_BP which Spawns Cards, and I have a Card_BP that applies the textures associated to every spawned card and gives them a drawing animation.
I had them both set to start with a BeginPay event for testing, but now I want to move forward and make the cards spawn whenever I click the deck.
The problem is how to make the OnClick() from one BP to affect the events of the other, and the solution apparently is Dispatcher events. But every example I find online uses the character BP or the level BP.
This is what I got and I’m not quite sure why it isn’t working.
I’d really appreciate your help.

BP_Card:

BP_Deck:

Hi, thanks for answering. I really suck at references with blueprints, should I cast to BP_Deck and get an owner?
As for the BeginPlay event on both BP, I had that for testing. I plan to use a Touch input.
If you could show me a screenshot or a step to step for the reference part, that’d be great.
I really don’t care if I sound dumb but that has proven to be my weak spot.

As you can see I created the dispatcher on deck as you told me and set it after the touch event.

Actually now that I see what your trying to do, there is no need for an event dispatcher here, because you are spawning the card there is a much easier ways to do this.

The first is simply remove the event dispatcher and just call spawn card from the deck. When the card spawns it will call event begin play on itself automatically, no need for a reference.

Deck BP:

Card BP:

Now if you want a reference easily, because your spawning, you can do this. I created a variable inside the card named “Deck Reference” and set its type to the deck. Then in the details panel of the variable I checked it to be “Instance Editable” and “Expose on Spawn”. This creates a pin of the Deck Reference type on the spawn node, and because the deck is spawning, it can passed in itself (Self). Now inside the card you can use the variable as a valid deck reference that you can use anytime you want because your setting the variable when you spawn it.

Deck BP:

Card BP:

You can also do the event dispatcher version but it takes more work, and is really only good if you want to send a mass signal to every single card that has already been spawned, and have them all respond to that signal. I that case I would use a combination of these methods, like this:

Expose the “Deck Reference” on spawn, the deck passess itself through on spawn, then the card can bind an event on its begin play to the decks dispatcher (effectively listening for the deck to now call the dispatcher):

Event Dispatcher Version.

Deck BP:

Card BP:

Thank you very much. The answer was quite silly actually but I wouldn’t’ve come to it on my own

You are welcome! I’m glad I could help. Could you please mark my answer as correct so others can easily find the solution as well? Thank you! :slight_smile:

Okay, I see your problem, your event dispatcher is setup backwards.

What you want to do is create an event dispatcher on your BP_Deck. Drag it out and “call” it from a custom event. Do not plug anything into target, it should be self.

Now here is the tricky part…

Inside your BP_Card you will need a reference to your BP_Deck, on begin play you can get the reference to BP_Deck drag off the reference output and bind a custom event to the Decks dispatcher.

The thing you will have to figure out is that this could not happen on begin play for BOTH classes, because the Card needs to get a reference to the Deck and bind an event to its dispatcher first before Deck calls the dispatcher event. Once the Card is setup then your Deck can safely call its dispatcher and the Card will always be listening for that call and will fire off its bound custom event when it hears the message.

I hope that helps!