Setting up environment - Godot with VSCode
Tags: gamedev, godot, beginners, tutorial
Published: 2023-12-29 12:13:39



## Summary

In this tutorial, I'm going to explore on how to set Godot (version 4.1, which can be found [here](https://godotengine.org/download/archive/)) with [VS Code](https://code.visualstudio.com/download) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3s68hadjo4w4omizqb10.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz60x28dm7yazj3v54hu.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6im2u5tmq0tjssmipbwo.png)

* 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfucfdb6lbjhxru3uovr.png)

* [C# Tools for Godot](https://github.com/godotengine/godot-csharp-vscode)
This extensions helps when using C# with Godot, and with debugging!
* [Godot files](https://github.com/AlfishSoftware/godot-files-vscode)
Helps with file paths resolve.
* [Godot tools](https://github.com/godotengine/godot-vscode-plugin)
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`:

```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
		  }
	]
}
```

## 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!