Creating an event to be fired from C++

Hello All,

I have been looking all over the web for the answer to this one but I’m getting confused and I don’t think some of the examples I found specifically show me what I need, so here is what I need help with.

I have C++ class that handles my TCPNetworking, When I get a response from the network I want to Fire and event from C++ so that my blueprint will act.

Example:

  1. Blueprint calls function in C++ to send login information to the server (working)
  2. Blueprint now waits for the response (working)
  3. When the C++ receives the message back from the server I would like to fire an event in Blueprint from C++ to continue with the login process.

Cheers

After posting I found a possible solution, Typical really.
Here is the link to the solution I got working.

https://answers.unrealengine.com/questions/31728/invoking-event-in-blueprint.html

Is this the recommended way? I appreciate this is only local to the class and will not allow the event to fire in all blueprints.

If anyone has further input that would be appreciated.

Thanks GrendelsMom,

Use the BlueprintImplentableEvent !
Create a member function in your class using:

UFUNCTION(BlueprintImplentableEvent, category = "YourCategory")
void MyEvent(/* Params*/);

Then, in your BP graph, search for your event’s name, to place it in the graph.
And when you call this function in your C++ code, it will call the Event in BP !

The BlueprintImplentableEvent way is more recommended, for what you are doing (see my answer for more informations).

Thanks for the comments,
I couldn’t get the event into a seperate blueprint so I used the following method.

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLoginResponseDelegate, bool, authenticated);

and its delegate

UPROPERTY(BlueprintAssignable, Category = "NDG Events")
		FLoginResponseDelegate OnLogonResponseDelegate;

Then called this with

OnLogonResponseDelegate.Broadcast(authenticated == 1 ? true : false);

This now allows me to just broadcast the message so any blueprint binding to this event will be fired which is perfect.

Note:
The authenticated in the Broadcast is 1 as this is returned via my server as a single bit received in the TCP packet.

Thanks for the assist and I appreciate the extra advice on using BlueprintImplentableEvent this will be required in later classes.

Hello, what do you think is the drawback if we use delegate (BlueprintAssignable) instead of function (BlueprintImplentableEvent)?