I recently installed UE4 and started trying out various demos. I encountered a strange bug for the twin stick shooter (C++ version) - whenever I move in a diagonal direction the motion is extremely slow. I checked, and the horizontal and vertical velocity would become 0.0125.
I tracked the error down to the InvSqrt function which called inside the GetClampedToMaxSize method. Next I tested with the following code:
FVector testVec(ForwardValue, RightValue, 0.0f);
float sqrSize = testVec.SizeSquared();
message = FString::Printf(TEXT("%f, %f, is equal = %d"), FMath::InvSqrt(sqrSize), FMath::InvSqrt(2.0f), sqrSize == 2.0f);
GEngine->AddOnScreenDebugMessage(2, 0, FColor::Blue, message);
which produced this:
The strange part is when I launched the program in “DebugGame Editor” mode, everything works correctly. What’s going on here?
Compiler: “C/C++ Optimizing Compiler Version 19.23.28106.4 for x64”
OS: Win10 pro
UE4: “Unreal Engine 4.23.1”