Download

Call a function when button clicked

I stuck with a very simple thing.

I made a Widget with a Button. I have two cameras in my Pawn and want to use this button to change the camera.
3.PNG

On my Pawn i made a EventDispatcher “WechselKamera”
2.PNG

How can i fire this Event “WechselKamera” from my Widget Button?
5d7d866b7260f7749f87d0056bb05d8ddbc65a44.png

I am sure this is very simple, but i can’t wind the answer in the documentation and youtube tutorials.

Thanks for your help!

You’ll want to get that controlled pawn, most likely through the Player Controller, and then cast from that Controlled Pawn to the WeschelKamera event. Then, when the OnClicked event occurs, it will call that event with the CranePawn as its target, and you should be in business.

PlayerController > Get Controlled Pawn > Cast to Controlled Pawn > WechselKamera (message)

I’m not at my home computer at the moment so I can’t test this, but that should work.

Cheers :slight_smile:

Thanks a lot TBWright.

That works for me. This is what i added on the Button:
f710f0680af4d343e84cede13872a82abcc6fcb2.png

Good to hear! Glad I could help =]