Strange behavior in trying to make custom events

I’ve been trying to create a Blueprint Event in C++ to use in my Blueprint Game Mode but am seeing some weird behaviour. The following code is inside my custom AGameMode class:

UFUNCTION( BlueprintImplementableEvent, Category = "MyMonitor", DisplayName = "onLogOnFailure" )
void blueprintEventOnLogOnFailure( uint8 statusCode, FText &fMessage );

It’s worth calling out that the compiler required that I used FText& instead of FText.

So I’ve compiled my code and open my Game Mode Blueprint to add the Event and it’s nowhere to be found in the “All Actions for this Blueprint” menu. Just to sanity check something simpler, I made a second Event (Similar to the above), but with no parameters, and it shows up fine and can be added to the Blueprint.

So I then took out the FText parameter for the Event, recompiled, and tried again. This time the event showed up in the “All Actions for this Blueprint” menu along with it’s byte parameter.

At this point I know the problem is narrowed down to the FText parameter, so I keep the node in the Blueprint, exit the editor, re-add the FText parameter into the code, recompile successfully and reopen the editor. I am greeted with this:

122863-eventerror.png

So what’s happening here? Is it a bug or am I doing something fundamentally wrong?

Also can I just double check that it’s correct for the uint8 to show up on the Blueprint Event node as a Byte? What types of uints will result in an Integer blueprint type?

First, try changing to: const FText &fMessage.

Blueprint is thinking you are trying to overwrite the already existing/defined event, hence the error.
When you see this error, try deleting the event, and re-creating it in blueprint.

You changed the structure of the method. Unreal most probably did not understand what is changed.

I just took a look at the generated cpp code:

void MyGameMode::blueprintEventOnLogOnFailure(uint8 statusCode, FText& fMessage)
{
	MyGameMode_eventblueprintEventOnLogOnFailure_Parms Parms;
	Parms.statusCode=statusCode;
	Parms.fMessage=fMessage;
	ProcessEvent(FindFunctionChecked(MYPROJECT_blueprintEventOnLogOnFailure),&Parms);
	fMessage=Parms.fMessage;
}

Is it just me or is it strange that it seems to be trying to set fMessage after ProcessEvent?

Thanks, after I added const to the FText parameter and then did your suggestion with the Blueprint it all started working as intended.

I’ve learnt the lesson about const’ing for event params the hard way :stuck_out_tongue: