Code does not work outside of debugging

When I put break points or log calls in code that did not seem to work–without otherwise modifying it–things work literally every time. Even weirder is that the log trick only works when I’m looking at the output log. If I have, say, the content browser open instead, it does not work. Would there be specific possibilities where this happens?

For example: There is an action bound to double-tapping a key, doThings() { addSomeWidgetToScreen(); }. No matter how quickly I attempt to double-tap it, nothing happens. However, if I put a breakpoint or call UE_LOG in doThings, and attempt to double tap again (even in the same running instance of the game), the breakpoint is hit or the log is written, and the function is successful. Or I tapped without looking at the log, then switched from the content browser to look at said log, and then it works.

Hello sgp,

Breakpoints are not intended to work outside of debugging due to how breakpoints work. Breakpoints halt the process that the debugger is attached to when said process reaches a certain line of code. Without the debugger attaching itself to the process, the breakpoint can’t halt anything.

As for the log messages, if you wish you print things out to the screen it would be best to use AddOnScreenDebugMessage instead of UE_LOG messages. You can find more about those output methods here:

I’m not quite sure I understand your example that you use however. Do you mean that if you set up a UE_LOG message to print, it won’t print unless you have the Output Log open when the event occurs? Are you sure it isn’t being pushed up the log by other messages?

My problem is not about breakpoints or logs not working, it’s that they cause my code to work–my code does not work unless I have a breakpoint, or unless I’m logging and looking at the log during play, which is pretty crazy. The example was to show that non-working code (adding widgets to the screen upon a button press in that case) suddenly works when one of the two things (breakpoints/logs) are done.

Ah, I misunderstood what you meant, because I’ve never heard of anything like that occurring. Does this only happen with the particular project that you’re working in? Is it only a few specific functions? Could you post the full code for some of these functions?