Input from BP does not get recognized in C++ function

Hi All,

I am inputting 4 float values and 1 int to a custom node in BP. Right before doing that, I let the engine print the values to the log. In the CPP Code, the first thing that I am doing is throwing an error message with the input values. However, the log shows that the input was not properly transferred.

Proof:

What I have tried:

  • Change the input definition in the header file to “const float” as well as to “float” only - to no avail
  • Promoted the input variables before sending them to CPP - also no effect

The Code:
.h file

UFUNCTION(BlueprintCallable, Category = "Settings Menu Keyboard Setup", meta = (DisplayName = "CPP Keyboard Line Adjustment", Keywords = "CPP"))
		static void KeyboardLineAdjustment(const float LineLength1, const float LineLength2, const float InfoGridMiddleX, const float InfoGridMiddleY, const int Index,
			float& NewLength1, float& NewLength2);

.cpp file

void UKeyboardSetup::KeyboardLineAdjustment(const float LineLength1, const float LineLength2, const float InfoGridMiddleX, const float InfoGridMiddleY, const int Index,
	float& NewLength1, float& NewLength2)
{
	UE_LOG(LogTemp, Error, TEXT("LineLength1: ") TEXT("%d") TEXT(" LineLength2: ") TEXT("%d") TEXT(" InfoGridMiddleX: ") TEXT("%d") TEXT(" InfoGridMiddleY: ") TEXT("%d") TEXT(" Index: ") TEXT("%d"), LineLength1, LineLength2, InfoGridMiddleX, InfoGridMiddleY, Index);

Apparently I am doing something wrong, but with the exact same setup, my other functions are working just fine.
Any help is appreciated, thanks very much!

IMO the problem is your UE_LOG. Try:

	UE_LOG(LogTemp, Error, TEXT("LineLength1: %f | LineLength2: %f | InfoGridMiddleX: %f | InfoGridMiddleY: %f | Index: %i"), LineLength1, LineLength2, InfoGridMiddleX, InfoGridMiddleY, Index);

or:

FString ToLog = FString::Printf(
	TEXT("LineLength1: %f | LineLength2: %f | InfoGridMiddleX: %f | InfoGridMiddleY: %f | Index: %i"),
	LineLength1,
	LineLength2,
	InfoGridMiddleX,
	InfoGridMiddleY,
	Index
);

UE_LOG(LogTemp, Error, TEXT("%s"), *ToLog);
2 Likes