logging simple float variables in Tick(float DeltaTime) function causes crash

Hi!

I have a problem with logging simple float variables for my Paper2D game in Tick(float DeltaTime) function. Everytime when I want to make sure what is the value of my float variable (even DeltaTime itself) the whole UE4 editor crashes and I have no clue what actually happened.

Whereever I define and initialize my variables - for example I’ve defined and initialized static and non-static variables in header file, in .cpp file in constructor and in Tick function itself. I don’ t understand what may cause this strange behaviour…

It’s strange, because it’s just about using simple float variables in one function, but the problem is I don’ t know where to look when something like this happens. Is there somekind of crash log? Anyways, I hope I’m not terribly mistaken and you know solution for my problem.

Thank you in advance! :slight_smile:

Hi. I clearly am an idiot. Sorry I had to say it out loud…
It seems I didn’ t use the UE_LOG function right…
I tried to log float values using “%s”. Instead I should have used “%f” as f stands for logging float values…

Anyways, sorry for the mess I caused…

Just leave the right example here.



 int intVar = 5;

float floatVar = 3.7f;

FString fstringVar = "an fstring variable";

**UE_LOG(LogTemp, Warning, TEXT("Text, %d %f %s"), intVar, floatVar, *fstringVar );**


Source: https://subscription.packtpub.com/book/game_development/9781785885549/1/ch01lvl1sec20/ue4-logging-with-ue-log

P. S.
UE4 should not crash but instead say what’s wrong with your code.

2 Likes

If the UE4 editor keeps crashing, then I believe there is a bug in the UE4 compiler and not in your code.
Keep that in mind.
UE4 editor is not supposed to crash at all.



FVector2D point;

//...

GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(point.ToString()));  // prints "X=0.000, Y=3.215"