{"id":30,"date":"2025-03-10T05:36:59","date_gmt":"2025-03-10T05:36:59","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/crashtocash\/?p=30"},"modified":"2025-03-10T05:43:25","modified_gmt":"2025-03-10T05:43:25","slug":"i-debug-in-the-psych-ward-not-starbucks","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/crashtocash\/2025\/03\/10\/i-debug-in-the-psych-ward-not-starbucks\/","title":{"rendered":"I Debug in the Psych Ward, Not Starbucks"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>Every programmer knows the feeling: you&#8217;re staring at your screen thinking, &#8220;The bug is fixed! Every possible cause of the error has been addressed and my tests pass!&#8221; and then you run it&#8230; and get the same exact error. The error points to a function in a library you are using and the stack trace is so deep that you are essentially drowning in code. That unsettling doubt creeps in: <em>Did I even cause this problem? Is this a bug in the library or another tool?<\/em> This blog post is about one of those awful moments where nothing made sense, and I questioned everything \u2014 even my sanity.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">My Role in the Project<\/h2>\n\n\n\n<p>For our game, my role focused on designing and implementing NPCs. This included creating dialogue systems, NPC pathfinding, and handling various interactions. One of the biggest challenges I faced was implementing Unity&#8217;s NavMesh system for NPC movement \u2014 something that should have been straightforward but ended up being a multi-day nightmare.<\/p>\n\n\n\n<p>Unity&#8217;s built-in NavMesh system doesn&#8217;t play nicely with 2D games, so I used a library called <strong>NavMeshPlus<\/strong>. While this tool was supposed to be &#8220;plug and play&#8221;, it instead introduced a bizarre issue that left me dangerously close to an involuntary commitment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Impossible Bug<\/h2>\n\n\n\n<p>Everything was going smoothly at first. I successfully baked the nav mesh, adjusted my NPC routes, and felt satisfied. But then I needed to adjust a few things \u2014 nothing major \u2014 so I cleared the nav mesh and tried to rebake it. And that&#8217;s when everything broke.<\/p>\n\n\n\n<p>The rebake refused to work. Every attempt ended with a <strong>NullReferenceException<\/strong> from the NavMeshPlus library. I retraced my steps, rewrote the code, reinstalled the library \u2014 nothing worked. I was positive my code was flawless; this <em>had<\/em> to be a bug in the library or Unity itself. The doubt crept in further: <em>Maybe the library was broken. Maybe I&#8217;m not the problem for once.<\/em><\/p>\n\n\n\n<p>Over the next few days, I spent roughly <strong>12 hours<\/strong> troubleshooting this one issue. I read forum posts, dug through GitHub issues, and examined the NavMeshPlus source code. Each dead end pushed me closer to that maddening belief that the tools themselves were failing me.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When Everything Just Worked but I Still Hate It<\/h2>\n\n\n\n<p>Eventually, I reached my breaking point. Out of desperation, I deleted the entire project from my system, cloned a fresh copy from our repository, and reimplemented my changes \u2014 step by step, exactly as I&#8217;d done before.<\/p>\n\n\n\n<p>To my disbelief, it worked perfectly. Same steps, same logic, same code (I even copy pasted it) \u2014 but this time, everything was fine. I had no explanation. Somehow, some file that wasn&#8217;t tracked in source control must have been causing an issue, and no amount of debugging would have found it. While I was relieved, the lack of a clear answer was maddening.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion: You&#8217;re Always the Problem<\/h2>\n\n\n\n<p>This experience taught me a crucial lesson: <strong>trust established tools, but always doubt your own work first.<\/strong> Unity and NavMeshPlus are widely used and well-maintained \u2014 far more reliable than my own code. It took me far too long to realize that the problem wasn\u2019t the library or Unity; it was something in my local environment.<\/p>\n\n\n\n<p>If you find yourself trapped in a debugging spiral, consider these tips:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Check your local environment.<\/strong> Unnoticed changes in non-tracked files can silently sabotage your progress.<\/li>\n\n\n\n<li><strong>Don&#8217;t lose faith in proven tools.<\/strong> Libraries like NavMeshPlus are far more stable than they may appear during moments of frustration.<\/li>\n\n\n\n<li><strong>Take breaks.<\/strong> Walking away for an hour might save you hours of fruitless trial and error.<\/li>\n<\/ul>\n\n\n\n<p>Most importantly, don\u2019t fall into the trap of thinking your tools are cursed. They probably aren\u2019t. It&#8217;s far more likely that something seemingly insignificant \u2014 some forgotten file or overlooked setting \u2014 is quietly wrecking your day. And sometimes, the best debugging tool is simply starting fresh.<\/p>\n\n\n\n<p>Trust me \u2014 you or your local environment are always the problem.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Every programmer knows the feeling: you&#8217;re staring at your screen thinking, &#8220;The bug is fixed! Every possible cause of the error has been addressed and my tests pass!&#8221; and then you run it&#8230; and get the same exact error. The error points to a function in a library you are using and the stack [&hellip;]<\/p>\n","protected":false},"author":14517,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/users\/14517"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":2,"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/posts\/30\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/media?parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/categories?post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/crashtocash\/wp-json\/wp\/v2\/tags?post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}