Tag Archives: godot

Debugging a Godot C# Project using Jetbrains RIder

Currently you know how to debug godot using vs code, but my personal favorite IDE is Jetbrains Rider because I know most of the hotkeys and I use their other IDE’s for work on a daily basis. Rider just made sense, plus nothing beats an IDE made for working with a language.

(We’ll be using this project for this example)

Setting up your godot project

So lets get right to it. The first process is similar to the vs code tutorial, we need to double check a few settings in your godot project. So first go to Project -> Project Settings -> Mono -> Debugger Agent and make sure “Wait For Debugger” is checked. Next we want to change the wait time, the time is set using milliseconds, I personally increased this value to 10 seconds because it gives you a little time to enable the debugger and let it set itself up before attaching itself to your godot project.

setup godot csharp jetbrains rider

Setting Remote Debugging in Jetbrains Rider

In order for jetbrains to connect to the mono debugger we need to setup our configuration. So first select the drop down below Tests and Tools menu and hit Edit Configuration. Next we want to add the new configuration by pressing the green plus symbol and selecting Mono Remote. From here we rename our remote debugger, I used “Godot” as the name, set our host and we want to share the remote debugger so check that option as well. We’ll leave the port default for now. Hit Apply then hit Okay.

jetbrains configuration godot 3 csharp remote debugging

Now we need to setup the port for Rider to match the debugger in Godot

First go back to your debugger settings in your godot project and copy the debugger port

copy port godot jetbrains remote debugger

Next we need to edit our configuration in jetbrains. So like we did before use the drop down and select edit configuration, find our remote mono configuration and paste the port we used in our godot project.

Lets Debug!

Now to debug it’s simple, I start by running the godot application either by individual scenes or the full game by pressing the play button either works. Wait for the window to popup then head over to jetbrains rider and hit the debug icon and wait a second. If successful you’ll see variables in the debugger and you should be able to do everything you could with the debugger such as step in, step out, etc… I will note that sometimes the debugger may not work, simply just repeat these steps and wait a second after the window launches before trying to debug and it should work normally.

jetbrains rider debug test godot csharp

Wait, I still can’t get debugging working in my current application!

There’s a chance that you have some unhandled exceptions in your application and the debugger by default does not catch them. Take a look here where I purposely add a NullReferenceException to my application.

exception jetbrains rider csharp

So how do you fix this you ask? It’s very simple. First click on the Run menu and go to the very bottom and select View Breakpoints or CTRL+Shift+F8 (on windows). Next check Any Exception under .NET Exception Breakpoints and try debugging again. (note: you can manually add specific exceptions if you highlight .NET Exception Breakpoints then hitting the Plus sign and typing in an exception name)

exception jetbrains rider csharp

And that’s about it. Happy Debugging!