Unreal Generation File Error

I have been coding a character class in C++, but I made a type once in the declaration of a parameter for a UFUNCTION, and now almost every time I compile, the gen.cpp file is messed up and doesn’t match what was written in the header file. Is there anything I can do to fix this permanently? Because I have to go into the gen file every time right now to fix it.

.h file code:

UFUNCTION(BlueprintImplementableEvent, category = Events)
void LookWidgetComponent(UPrimitiveComponent* ComponentHit, FText OutText);

gen.cpp file “code”

static FName NAME_AFreeRoamPlayerV2_LookWidgetComponent = FName(TEXT("LookWidgetComponent"));
void AFreeRoamPlayerV2::LookWidgetComponent(UPrimitiveComponent* ComponentHit, const FText& OutText)
{
	FreeRoamPlayerV2_eventLookWidgetComponent_Parms Parms;
	Parms.ComponentHit=ComponentHit;
	Parms.OutText=OutText;
	ProcessEvent(FindFunctionChecked(NAME_AFreeRoamPlayerV2_LookWidgetComponent),&Parms);
}

Generated files are dynamically generated on compile.
You can delete the intermediate and binary folders and just regenerate them.

I tried doing this multiple times, but for some reason keeps generating it wrong

I’m surprised your code compiles.
I only got it to compile after making the following changes
.h

	UFUNCTION(BlueprintImplementableEvent, category = "Events")
	void LookWidgetComponent(UPrimitiveComponent* ComponentHit, FText &OutText);
	virtual void LookWidgetComponent_Implementation(UPrimitiveComponent* ComponentHit, FText& OutText);

.cpp


void AFreeRoamPlayerV2::LookWidgetComponent_Implementation(UPrimitiveComponent* ComponentHit, FText &OutText)
{
	// Your code here
}

The issue is that: FText& OutText is supposed to be: FText OutText But the Engine doesn’t generate it to be that. OutText shouldn’t be a reference variable, but for some reason, the engine keeps thinking it is

Try

	UFUNCTION(BlueprintImplementableEvent, category = "Events")
	void LookWidgetComponent(UPrimitiveComponent* ComponentHit, UPARAM(ref) FText &OutText);
	virtual void LookWidgetComponent_Implementation(UPrimitiveComponent* ComponentHit, UPARAM(ref) FText &OutText);

After implementing in blueprint you get this:

cpp stays the same

Never mind, I apparently wasn’t aware of how to properly declare an FText in an implementable event and that: const FText& OutText is how it’s supposed to be in the method parameter declarations

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.