Download

Binding delegate in PlayerController to Widget function

I have a delegate defined in PlayerController as follows …

DECLARE_DYNAMIC_DELEGATE(FOnCharacterFoundDispatcher)
FOnCharacterFoundDispatcher OnCharacterFound

I have a widget in which 2 functions are declared as follows …

UFUNCTION()
void CallCharacterLoaded();

UFUNCTION(BlueprintImplementableEvent)
void OnCharacterLoaded();

When I create the widget in PlayerController I bind to it as follows …

OnCharacterFound.BindDynamic(CharacterSelectMenu, &UCharacterSelectMenuBase::CallCharacterLoaded);

Output confirms that this binding is successful. This shows in the client window.

I load the character from disk, server side. When successful I attempt to execute the delegate as follows …

OnCharacterFound.Execute();

But output reports that the delegate is unbound. This shows in the server window.
The widget is displayed as expected and the character is indeed loaded from disk as expected.
I can’t work out how to bind to this delegate on the server side, if that makes any sense.
Can anyone help?

Regards, Grover



// Declaring a blueprintable delegate.
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnSomethingHappenedSignature);
FOnSomethingHappenedSignature OnSomethingHappened;

// Binding a function to said delegate.
OnSomethingHappened.AddDynamic(this, &AMyActor::HandleOnSomethingHappened);

// Broadcasting the delegate.
OnSomethingHappened.Broadcast();


The server doesn’t run the GUI, right?

Thanks STRiFE.x but changing from single-cast to multi-cast won’t help.
It’s more of a “scope” issue.

CharacterSelectMenu is a member of PlayerController.
However, when I tried to bind to CallCharacterLoaded on the server side, right before the Load attempt, CharacterSelectMenu is NULL. So it seems I need the menu to be valid on both client and server sides.

That’s correct jwatte, the server doesn’t run the GUI.
I’ll try to restructure the code tonight. Moving the widget creation to GameInstance, but I’m doubtful. Some of my delegate works fine, some don’t. I spend days pulling my hair out over these. I’m almost bald. :’(

Believe it or not I started working on this game concept 30 years ago, on an Amiga 2000. Life, careers and children got in the way. About a year ago I saw that UE offered a lot of promise, so I developed a prototype in Blueprints. It got terribly convoluted and did my head in , so I let it rest for 6 months. Now I’m rewriting in C++. I am a developer, by trade, but not at this level. VB, C# and 4GLs, application specific stuff. If I can get this thing working and reveal to a promoter it will offer a new genre of career for gamers and will be an avenue for much indie development, landscape artists, 3D modellers, animators, audio etc.
Tis’ my raison d’etre :slight_smile: