# Code does not work outside of debugging

**URL:** <https://forums.unrealengine.com/t/code-does-not-work-outside-of-debugging/341389>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** error, unreal-engine, CPP, question\
**Created:** [December 14, 2015, 2:52am UTC](https://forums.unrealengine.com/t/code-does-not-work-outside-of-debugging/341389 "2015-12-14T02:52:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_8b77cbb9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8b77cbb9](https://forums.unrealengine.com/u/anonymous_user_8b77cbb9)\
**Post date:** [December 14, 2015, 2:52am UTC](https://forums.unrealengine.com/t/code-does-not-work-outside-of-debugging/341389/1 "2015-12-14T02:52:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [December 14, 2015, 6:02pm UTC](https://forums.unrealengine.com/t/code-does-not-work-outside-of-debugging/341389/2 "2015-12-14T18:02:20Z")

</div>

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:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

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?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8b77cbb9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8b77cbb9](https://forums.unrealengine.com/u/anonymous_user_8b77cbb9)\
**Post date:** [December 14, 2015, 10:48pm UTC](https://forums.unrealengine.com/t/code-does-not-work-outside-of-debugging/341389/3 "2015-12-14T22:48:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [December 15, 2015, 10:04pm UTC](https://forums.unrealengine.com/t/code-does-not-work-outside-of-debugging/341389/4 "2015-12-15T22:04:21Z")

</div>

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?
