Category Archives: Godot

Building Android Templates For your Godot C# (Mono) Project on Linux

Hi so this tutorial is going to be very precise, no shortcuts and it expects that you know how to use linux terminal and build things from command. When you’re building, you might see warnings which can be ignored, sometimes you may see an error and if rerunning the scons build doesn’t fix that error that means you either did something wrong or there is an issue that needs to be solved and it’s best to report it on the godot github issue tracker.


  • Terminal (because you’ll be doing all this from terminal)
  • Python 2.7 or 3 (not sure if it matters, as long as scons runs)
  • Scons 3.0
  • Git
  • Android Studio (For installing SDK AND NDK-Bundle AND cmake)
  • Mono (I’m using 6.0.0 stable – editor & templates must be built from the same mono version and exporting must use the same mono version) [install specific version of mono]
  • Java (OpenJDK 1.8) [Scroll down to ‘Installing Specific Versions of OpenJDK‘ and follow those steps]
  • Distro specific one liners [to save you some time this will trying to install every build requirement such scons, libx11-develop, etc..]

Make sure you setup all these requirements first or you’ll end up being told what tools you’re missing when trying to build.

Continue reading

Quick Start Guide to Godot 3.1 on Windows 10 using C# & Jetbrains Rider

(Note: If you like this article you can support me by using my referral link, and by using my referral link you are directly supporting my blogs that are hosted there. Also follow me on social media: @IMG4MR/G4MR)

Godot 3.1 was recently released and now is a good time to get more people trying it out. This version of godot makes it even easier to get up and running because it takes less work and this quick start is going to be an introductory guide on helping you do just that.

This guide expects you to understand how to install software, and a mild understanding of your editorial software/ide. For this quick start we’ll be using Jetbrains Rider, but the default preferred editor is Visual Studio Code because it’s just as easy to setup remote debugging with the mono runtime. You can use my guide here if you prefer to use Visual Studio Code. Then come back to this tutorial and we can get started.


  • Godot 3.1
  • MSBuild (via Visual Studio/Visual Studio Tools/Mono)

Godot 3.1 is more streamlined than before, requires less to get started. First and foremost it’s recommended that you download the latest godot stable from the website. Make sure you’re using the version listed under Mono version and install (move) it to your preferred folder location and create a shortcut of the exe if necessary. (note: the steam version does not include the mono build, I’m sure there will be a mono version released sometime in the future on steam)

(heed the note under the download buttons) Continue reading

Godot Tilemap Collision Detection & Finding the Corresponding Colliding Cell

So I’ve been working on a gamejam called the godot wild jam 5, and I will release source when I’m finish (hopefully I pull through, only have a few days left to get this done), and I ran into an issue with godot’s tilemaps. Basically the way godot’s tilemaps work from my understanding is in order for you to get collision detection you have to create your own tileset from nodes using staticbody2d’s with collisionshape2d’s as a child. That way you can in fact tell when you are colliding into other objects.

There were two issues I ran into, the first one being I couldn’t figure out how to deal with tilemaps that were scaled in a parent node up/down. The second issue was related to that and figuring out how to get the cell that my player touched. I have a solution to both.

First and foremost for this example to work you need to have your player node be a kinematicbody2d. The reason for this is because KinematicBody2D allows you to get some collision data that other nodes won’t give you without using a raycaster which I have no experience with at this time. That collision data comes from a method called move_and_collide or (MoveAndCollide for c#). This returns a KinematicCollision2D that gives you basic information on the object you collided with and the position of the object that you just collided with.

From here it made sense to subtract my current players position from that colliders position to figure out the direction of where the collision was coming from and in our case we wanted to know if it was TR, TL, BR, BL, T, R, B, L (top right, top left, etc…) that way we could determine the exact cell location that tile is located from my current position.

You wouldn’t think it would be that simple, but it was and here is the code on how I did that and I’ll add an example project of me reproducing it using gdscript for the sake of having an example available online somewhere.

So to explain what’s happening here in this example. First we check every physics frame if we’re moving and attempt to get the collision data. Then if we have collided with something we call a handle collision function to figure out if we collided with a tilemap (you can get more specific when working with more tilemaps, like the name, etc…) then I create a temporary vector2 to store our collision cell location data in. We need to determine what side the collision was handled on from our current player cell’s position. This is when we say look, we have a 3×3 tile section that we need to figure out which of the 8 other tiles from the center position that we are touching and to do that we simply figure out if the touching tile is greater than or less than the x and y position and we either add or subtract from 0 to determine that. Or we leave it at zero and do nothing meaning we’re on the same cell row or column so it’ll either be directly T, L, B, or R.

Now after we’ve figured out the cell’s location from our player location (this works even when the data is scaled, it’s pretty nifty) – we need to say hey where the hell exactly is our player’s cell location on the tilemap’s grid. We use world_to_map to determine this information. Now we want to take our player’s position and convert it to the local coordinates of the tilemap. This is useful if our tilemap has been scaled down to fit inside of something. So we need to first convert the players position to local coordinates to get the proper map location that our player is located at inside of that tilemap. To do that we call to_local from the tilemap node. Only nodes that derive from a Node2D have these methods.

So we have the exact player cell location within that tilemap and we also know the location of our collision tilemap cell, all we have to do now is add it to the value we get from world_to_map and then use that data and pass it to get_cellv to get the exact cell index in the tilemap and you can do what ever you want with that data. Edit the tilemap by removing the cell block, it doesn’t matter.

Hope this helped you understand how to get the tilemap’s tile cell point when colliding with a tilemap using a kinematicbody2d 🙂

Download (godot project 3.1beta)

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!

Catching Exceptions when debugging your c# godot projects using visual studio code & Mono Debug Extension

So the guys over at Godosharp.Net wrote an article on how to setup the mono-debug extension to work with your godot projects. Well currently out of the box exceptions are not caught by default and you may want to catch NullReferenceException‘s when working on your games. So after combing through some source on the plugin I figured out how to do just that.

First you need to open your user settings.

As long as you have the Mono Debug extension installed start typing mono-debug and it should auto complete. If the auto complete doesn’t work you can simply add the following setting block to your user settings file and restart the editor.

Now to test add something like public Random Rand; to your scene script and try to debug. Currently we only have NullRefenceException enabled, but you can choose between never, always and unhandled. In the above settings to catch exceptions.

Happy Debugging!