Binding UObject Callbacks (Unreal)

Hello,

I’m trying to bind the Nakama Client delegates to function callbacks in Unreal 5.2.

class NAKAMAUNREAL_API UNakamaClient : public UObject

since the client is a UObject and has the delegates defined as:
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnUserAccountInfo, const FNakamaAccount&, AccountData);

I would think that this kind of call would work (this is happening on authentication success hence the login data with vars)

		Client->GetAccount(
			LoginData,
			FOnUserAccountInfo::CreateUObject(this, &MyClass::OnGetAccountSuccess),
			FOnError::CreateUObject(this, &MyClass::OnGetAccountError)

		);

using the appropriate function signatures:

	UFUNCTION()
	void OnGetAccountSuccess(const FNakamaAccount& AccountData); 

	UFUNCTION()
	void OnGetAccountError(const FNakamaError& Error);

but I am getting an error
Error C2039 : 'CreateUObject': is not a member of 'FOnUserAccountInfo

I tried putting “NakamaUnreal” and “NakamaCore” in the build.cs file but no luck
What’s the correct way to write these?

Hi @Tommie,

It’s best to use the AddDynamic for that situation like:

Client->GetAccount(LoginData);

Client->OnUserAccountInfo.AddDynamic(this, &MyClass::OnGetAccountSuccess);
Client->OnError.AddDynamic(this, &MyClass::OnGetAccountError);

You can also look at the documentation for further information on this: Unreal - Heroic Labs Documentation

Let me know if this works.