DEV Community

Cover image for Setting up environment - Godot with VSCode
Eduardo Julião
Eduardo Julião

Posted on • Updated on • Originally published at xuxudevchronicle.com

Setting up environment - Godot with VSCode

Summary

In this tutorial, I'm going to explore on how to set Godot (version 4.1, which can be found here) with VS Code on Windows!

Requisites

We're going to need to Godot and VS Code installed, alongside some extensions, which I'm going to list them when we're setting up VS Code.

Godot

But first, let's change some things in Godot!
In the top bar, select Editor > Editor Settings

Image description

Once the new window is open, navigate to Text Editor > External

Image description

Here, we're going to set up some properties:

  • Use External Editor
    This property must be checked, marking it to be true. This will tell Godot that you want to use other editor to edit your scripts.

  • Exec Path
    This is the path to the external editor .exe file, in our case, VS Code. Grab the full path with the .exe file name and paste it here.

  • Exec Flags
    Last but not least, we need to use some flags to start VS Code properly: {project} --goto {file}:{line}:{col}.

Now we need to make sure the Language Server is correct, in the same window, navigate to Network > Language Server.

Image description

  • Remote Server
    You can leave as 127.0.0.1

  • Remote Port
    Make sure it's set to 6005, as the VS Code will use this port to communicate. It can be changed to another port, but you'll need to update in VS Code settings so they can match.

  • Enable Smart Resolve / Show Native Symbols in Editor
    Set these two properties to true as will help with IntelliSense.

  • Use Thread
    ¯\(ツ)
    I leave it off as it makes no difference.

Ok, everything is set up in Godot, now we need to make some changes in VS Code!

VS Code

Let's start by installing some Extensions.

Extensions

Image description

  • C# Tools for Godot This extensions helps when using C# with Godot, and with debugging!
  • Godot files Helps with file paths resolve.
  • Godot tools The main Extension we need, this extension will connect with Godot Engine through the ports that we stetted previously and make the editor work 😄

Settings

Once the extensions are installed, we need to change some settings.

Open VS Code settings and search for Gdscript_lsp_server_port, make sure it's set up to 6005 (the same port we setup before in Godot).

Debugging

To create a new launch.json file, open Run and Debug on the left panel of VS Code > Create a launch.json file > GDScript Godot Debug.

Here's the settings I'm using for the launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Godot",
            "type": "godot",
            "request": "launch",
            "project": "${workspaceFolder}",
            "port": 6006,
            "debugServer": 6006,
            "address": "127.0.0.1",
            "launch_game_instance": true,
            "launch_scene": false
          }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Conclusion

And you're all setup! If everything was done correctly, pressing F5 in VS Code will start Godot and you're ready to run your game!

Notes

  • Godot needs to be open for the language server to run, without it, there will be no IntelliSense.
  • This tutorial was tested using GDScript language, I'm not sure if this works with C# or C++.

If you need more help or anything in this guide is difficult to understand or wrong, let me know!

Thank you!

Hope you find this article helpful!

See you in the next one!

Top comments (0)