Error message: trying to invert a NIL matrix, this results in NaNs!

Hi,

for a while I’ve been getting this error in the Output Log and I have failed to figure out why.
It just appears seemingly randomly.

LogUnrealMath: Error: TMatrix::InverseFast(), trying to invert a NIL matrix, this results in NaNs! Use Inverse() instead.
LogUnrealMath: Error: TMatrix::InverseFast(), trying to invert a non-invertible matrix, this results in NaNs! Use Inverse() instead.

Also once after editor startup and starting PIE, I get this:

LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: false [File:D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Math\Matrix.h] [Line: 429]
LogOutputDevice: Error: TMatrix::InverseFast(), trying to invert a NIL matrix, this results in NaNs! Use Inverse() instead.
LogOutputDevice: Error: Stack:
LogOutputDevice: Error: [Callstack] 0x00007ffb03820298 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb0243633a UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb02425fc2 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb0248d6d3 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb0246415a UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb023e5afb UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb031c6496 UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb0317d4fa UnrealEditor-Renderer.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb4df8c2f5 UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb4dfb9fff UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb2a572722 UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb2a567d4a UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb2a5681ee UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb4dfe894c UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb4dfed9e4 UnrealEditor-RenderCore.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb2ab9c0ad UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb2ab935cf UnrealEditor-Core.dll!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb8a41e8d7 KERNEL32.DLL!UnknownFunction
LogOutputDevice: Error: [Callstack] 0x00007ffb8af1c34c ntdll.dll!UnknownFunction

I have no idea where this is coming from.
I’m only using blueprints.

Any ideas where I can start?

Just a guess, but looks like a view matrix or something associated with the camera. To invert a matrix, the determinant needs to be non zero. So if it has NaNs or is zero, you’ll get this error. But I’m not sure why it would need an inverse. Usually, the inverse is used when you click on the screen and you want to know what asset is under the mouse. Are you doing any line traces (based on screen coordinates) or anything like that (getting 3d position under mouse) when your game starts? Or anything that takes screen coordinates and converts to world 3d coordinates? Or a widget or decal that is based on the center of the screen (or any screen location) and you’re trying to project that into the scene? ANYTHING that goes from screen to 3d world coordinates? That’s where I’d start looking.

I’m guessing you’re not building the engine from source or you would have debug info and could see the names of the functions, correct?

Thanks for the reply!
I have finally found the solution after narrowing it down for 2 hours.
It was related to static meshes I was spawning!
I would’ve never thought that static meshes could be the culprit.
When opening the folder that contained the meshes in the content browser I would also get the error in the output log.
Reimporting them also didn’t fix it.
Then I got this error message:

LogStaticMesh: Warning: The difference between RenderData Bounds (Origin=X=0.000 Y=0.000 Z=0.000, BoxExtent=(X=0.000 Y=0.000 Z=0.000), SphereRadius=(0.000000)) and MeshDescription Bounds (Origin=X=2538.330 Y=5881.262 Z=-136.763, BoxExtent=(X=2538.330 Y=1311.599 Z=3328.858), SphereRadius=(4382.041629)) is significative for StaticMesh /Game/Meshes/EnemyBase/Enemy_Base_Ring_3_Variant_2.Enemy_Base_Ring_3_Variant_2

So in the end I completely deleted them from the project and re-imported them from FBX, now it works.
Crazy!

Glad you fixed it!