# Best Practices for Passing Button On Click Event to Player Pawn (Event Dispatcher or Object Reference?)

**URL:** <https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734>\
**Category:** Programming & Scripting\
**Tags:** hud-blueprint, event-dispatcher, click-event, unreal-engine, pawn, question\
**Created:** [January 5, 2024, 4:54pm UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734 "2024-01-05T16:54:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThePDub](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thepdub/32/719651_2.png) [@ThePDub](https://forums.unrealengine.com/u/ThePDub)\
**Post date:** [January 5, 2024, 4:54pm UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/1 "2024-01-05T16:54:18Z")

</div>

Hi all!

I am making a small management-style game where you place buildings. I want a menu to initiate the ability to place buildings, so I want to pass a button click event from my HUD (which I created and overrode in my Game Mode) to the Player Pawn.

I was able to pass an event by binding an event dispatcher but it feels like a lot of heavy lifting for communication between just two blueprints (I don’t think I will need more than one blueprint to listen for this click event).

Here is my work-in-progress, does anyone have any suggestions for a better setup?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/2/fd288af813d96a220840a2d7b5d4f90258d3fb65.png)

Is it better to just have an object reference to the button itself instead of an event dispatcher? I am hesitant to do so much work on Begin Play. Would I have to do this for every button?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/b/72bd1be0e74e4c7a22c8cced688803e4ebae4381.png)

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [January 5, 2024, 5:21pm UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/2 "2024-01-05T17:21:57Z")

</div>

I’d go with interface calls instead.

Then your UI can always stay the same, and whatver you implement on whatever receives the message/implements the interface can change at will.

---

<div class="post-metadata">

**Author:** ![ThePDub](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thepdub/32/719651_2.png) [@ThePDub](https://forums.unrealengine.com/u/ThePDub)\
**Post date:** [January 5, 2024, 7:38pm UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/3 "2024-01-05T19:38:31Z")

</div>

Like this here my friend? [Blueprint Interface in Unreal Engine | Unreal Engine 5.3 Documentation](https://docs.unrealengine.com/5.3/en-US/blueprint-interface-in-unreal-engine/)

---

<div class="post-metadata">

**Author:** ![ThePDub](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thepdub/32/719651_2.png) [@ThePDub](https://forums.unrealengine.com/u/ThePDub)\
**Post date:** [January 5, 2024, 10:33pm UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/4 "2024-01-05T22:33:01Z")

</div>

I suppose here is a different way to phrase the question: design-wise, does it make sense to directly communicate between the player pawn blueprint and the HUD? Any issue with the HUD holding a reference to the player controller or player pawn?

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [January 6, 2024, 6:08am UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/5 "2024-01-06T06:08:51Z")

</div>

Well yes, references can break.

Does it matter? Probably not. Just make a function that seeks out the correct pawn and if your reference ever fails to validate you just run the function again…

---

<div class="post-metadata">

**Author:** ![ThePDub](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/thepdub/32/719651_2.png) [@ThePDub](https://forums.unrealengine.com/u/ThePDub)\
**Post date:** [January 6, 2024, 11:33am UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/6 "2024-01-06T11:33:32Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 5, 2024, 11:33am UTC](https://forums.unrealengine.com/t/best-practices-for-passing-button-on-click-event-to-player-pawn-event-dispatcher-or-object-reference/1590734/7 "2024-02-05T11:33:33Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
