So recently I came across Godot from a reddit post because I got inspired to get back into gamedev. Problem was I couldn’t figured out a language to use because the languages I wanted to use is either not recommended for desktop game development (Java/Kotlin) or still in development without full windows support (Crystal). My friends been using unity lately and has been inspiring me, but I remember when Unity got it’s 2D support and I was excited to try it back then. When I thought about my experience I always had in the back of my mind how the latest C# support wasn’t really there yet, but it was improving and the scripting api was a mess (in my eyes).
I checked out godot’s website and skimmed the news and noticed oh cool 3.0 is almost out, what I failed to realize was 3.0 was already out I was just reading an old RC post and some how missed the announcement post and got really excited. I checked out the new docs for 3.0 and man does it look great. Although I do think getting things setup on windows could improve, everything else is spot on! Loving it guys, keep up the great work.
So I bit the bullet and downloaded 3.0, had issues right away and then by the power of a lot of googling I came across two videos which saved me hours of stress (also please go check out their godot content and support those guys).
Now I didn’t know a lot of things regarding godot, like that I needed to rebuild it to make it properly work for me on my machine. So with a few guides (including the videos above) I ran into some common pitfalls and hopefully this guide should help you get EVERYTHING ready to make this go as smoothly as possible.
The following are things I used to build and get c# working with intellisense out of the box using visual studio code.
- Visual Studio Build Tools 2017 (
you can use 2017 if you like, I’m using 2015Seems like 2015 doesn’t like godot anymore, use ’17)
- dotNET SDK
- Visual Studio Code
- C# Extension for Visual Studio Code (powered by Omnisharp)
- Windows 8 (.NET 4.5) SDK (Look under “Earlier Releases” and find Windows 8 – for whatever reason I needed this for mono to properly work inside godot)
- Mono Project 64bit (Latest) – I’m using 5.8
- Python 2.7 – (used for scons)
- Scons 3.0.0 Windows Installer (tested with 3.0.0, couldn’t find installer for 3.0.1, links broken)
- Git (Latest)
Alright, all the above is everything I needed to get godot compiling properly, and getting the scripts to work properly in visual studio code.
Setting up Scons
I had a little issue with scons when trying to figure out how to get it to work, but it looks like I just needed to make sure python and the python scripts path was added to my windows paths and I could call scons from the command line which should spit out some weird error instead of command doesn’t exist.
Above paths where # is your Drive where python folder is installed because when you run the scons installer it’ll look for the python27 folder and install there. Simple enough.
Building Godot 3
Firstly I’m going to direct you to the official docs regarding building in case my instructions aren’t clear. I didn’t use Pywin32, then again I have an i7 4790K cpu so the build speed wasn’t too slow, but probably could’ve been faster if I followed the official docs instead of 3rd party sources. Pywin32 is completely optional though not needed for this tutorial.
So the first thing you need to do is open the visual studio build tools command line. This does some fancy stuff like properly finding environment variables to let scons properly compile godot. Read the docs for more information on that. Now open your windows search menu and type in Visual Studio C++ 2015 and you should see a list of options that look like the following:
The one you want is VIsual C++ 2015 x64 Native Build Tools Command Prompt or x86 for 32bit version of godot and mono. Make sure your mono installation matches the version you’re building (64bit mono + 64 bit build tool and vice versa).
(Note: You could also open up the windows start menu and select “V” and look under Visual C++ Build Tools to find the same exe. Also you don’t need to run this as administrator)
Cloning the Repo
Now that the visual c++ command prompt is open travel to the drive’s home path so in my case it’s C:\. Create a temporary directory called temp and travel inside the directory.
Go to the git repo and find the clone path for the version of godot you’re trying to build, we’ll be building master for now. Try other releases if master gives you problems.
Type git clone repo/link to clone the repo inside of the current temp directory. It’ll look something like this:
git clone https://github.com/godotengine/godot.git
Now travel inside of the repo path so you can build the project.
Building godot with mono support
This next part is pretty simple. If you’ve already installed Mono (which you should have), it’ll come with MSBuild 15.0 and you won’t have to deal with finding MSBuild yourself. Mono should’ve already added itself to your paths and you’re already set for building the project.
We need to build godot twice, once without and once with mono glue. The first time allows us to get the mono modules to support C# scripting and the second build is to allow us to use C# scripts with mono support. So first lets build godot to generate our modules and to do that you need to run:
scons p=windows tools=yes module_mono_enabled=yes mono_glue=no
Now you have to wait a bit, check the docs if you want to speed up building with Pywin32. Could take upwards to 10-15 minutes depending on the speed of your cpu. Once the build is complete it’ll let you know and if you have any errors go back and make sure you didn’t miss installing any of the requirements I listed above and if you continue to have issues check the docs and let me know if I missed any steps as I’m a bit tired writing this as I just got done getting this to work perfectly for me.
Once that’s done go to the bin folder and get the exe name and copy it to your clipboard. In my case the exe is godot.windows.tools.64.mono.exe. Now we need go back to the root godot folder to generate the glue code so we can rebuild w/ modules supported. So type the following in the command prompt:
bin\godot.windows.tools.64.mono.exe --generate-mono-glue modules/mono/glue
If that doesn’t work go back to the bin folder and try:
godot.windows.tools.64.mono.exe --generate-mono-glue ../modules/mono/glue
Which should do the same thing. Once that’s finished we need to rebuild godot with mono support. So type the following command and we’re done with the editor:
scons p=windows target=release_debug tools=yes module_mono_enabled=yes
You may also need export templates so the follow commands will do just fine:
scons p=windows target=release tools=no module_mono_enabled=yes
scons p=windows target=debug tools=no module_mono_enabled=yes
Now you should be set on the build process. Move the godot folder to wherever you want and you should be able to execute it without any issues.
Testing Visual Studio Code
If you’ve never started up visual studio code just start it up and keep it open. Then with godot create a new scene and save it. Now create a new Panel and save it. Create a sub Label node and rename it to “my_label” and edit the text to say anything really. Press the play button to make sure godot runs and shows the text.
Update: forgot one important note, make sure in editor settings under Mono -> Builds that you select MS Build (System) instead on windows. This worked wonders for me, thanks to this guy for the suggestion.
Go to editor -> editor settings and select Visual Studio Code from the External Editior drop down option. Now add a script to the label and select C# from the language drop down and hit create. This should open my_label.cs in visual studio code without any issue. Inside the _Ready() methods body add the following:
Don’t copy and paste the above because we want to make sure the intellisense/autocomplete works. When typing GD. you should see a bunch of methods after the period and Print should be one of the methods in the list as you type. If you see that you have completed the setup of Godot and I hope you have fun going through the Step By Step tutorial and learn about the editor and scripting to start making your first game!