I spent days trying to track some arbitrary bugs in my game (some collisions would stop working on some actors). But I failed to track down the bugs, the code seems fine, but somehow it happens differently in the game.
Eventually I found that: 1) the bug only happens on PIE, if I package the game, the packaged build will work perfectly. 2) if press CTRL+F5 in VS to run without debugger and then the bug happens in PIE, all I have to do is close the editor -> run with a debugger (F5 in VS), close the editor again -> now press CTRL+F5 to run the game again. And now it will work perfectly!
I just compiled the same code. Twice. The first time it didn’t work, the second time it did. From time to time the bug will happen again. And all I have to do is repeat the same dance: close, F5, close, CTRL F5, fixed.
Why does this happen? How do I even begin to debug this? Does it mean it’s not a problem in my code? Or is it?
I’m using UE4.25 with VS2019. The bug happens when I Run with “Development Editor” build configuration. I already tried: “Refresh visual studio 2019 project” and tried deleting Intermediate and Saved folders. Bug continued.