Skip to content
Search

Godot

lastmod 2025-11-07created 2019-10-16202 edits

Godot is a 2D and 3D, cross-platform, free and open-source game engine released under the MIT license. It was initially developed by Juan Linietsky and Ariel Manzur for several companies in Latin America prior to its public release. The development environment runs on multiple operating systems including Linux, macOS, and Windows. Godot can create games targeting PC, mobile, and web platforms.

Categories

Math

Export

Script

Node

Resource

Godot:ProjectSettings

APIs/Classes

Extension & Plugins & Projects

Samples

GDQuest Demos

Demos in the https://github.com/gdquest-demos repository

Dungeon Generation

Particle

Editors

Debug

Godot Compiling

  • Compiling — Godot Engine (stable) documentation (Korean)
  • Introduction to the buildsystem
  • Godot:Compiling:Windows - Compiling for Windows
  • Godot:Compiling:X11 - Compiling for X11 (Linux, *BSD)
  • Godot:Compiling:macOS - Compiling for macOS
  • Godot:Compiling:Android - Compiling for Android
  • Godot:Compiling:iOS - Compiling for iOS
  • Cross-compiling for iOS on Linux
  • Compiling for Universal Windows Platform
  • Godot:Compiling:Web - Compiling for the Web
  • Godot:Compiling:Mono - Compiling with Mono
  • Optimizing a build for size
  • Compiling with script encryption key

Supporting multiple resolutions

How to install

Arch Linux

Install the mono version of godot from the AUR.

$ git clone https://aur.archlinux.org/godot-mono-bin.git
$ cd godot-mono-bin/
$ makepkg -si

Alternatively, if you want to install the mono binary from the homepage yourself, add the following dependencies.

$ sudo pacman -S mono dotnet-sdk msbuild

GNOME Desktop Icon

The logo svg can be downloaded from the homepage/download page1. (Direct download: Godot_logo.svg.zip)

Create the file ~/.local/share/applications/godot.desktop and paste in the following.

[Desktop Entry]
Version=1.5
Type=Application
Name=Godot Engine
Icon=/home/your/Applications/godot/godot_logo.svg
Exec="/home/your/Applications/godot/Godot_v3.4-stable_mono_x11.64" %f
Comment=Free and open source 2D and 3D game engine
Categories=Development;IDE;
Terminal=false
StartupNotify=true

External text editor

How to connect an external text editor:

Check under Editor -> Editor Settings -> Text Editor -> External.

Godot will replace the following inside the flags parameter:

Field in Exec Flags

Is replaced with

{project}

The absolute path to the project directory

{file}

The absolute path to the file

{col}

The column number of the error

{line}

The line number of the error

Some example Exec Flags for various editors include:

Editor

Exec Flags

geany/kate

{file} –line {line} –column {col}

atom/sublime text

{file}:{line}

visual studio code

{project} –goto {file}:{line}:{col}

File paths in Godot projects

Accessing persistent user data

Locations of files starting with user://:

Type

Location

Default

  • Windows: %APPDATA%\Godot\app_userdata\[project_name]
  • macOS: ~/Library/Application Support/Godot/app_userdata/[project_name]
  • Linux: ~/.local/share/godot/app_userdata/[project_name]

Custom dir

  • Windows: %APPDATA%\[project_name]
  • macOS: ~/Library/Application Support/[project_name]
  • Linux: ~/.local/share/[project_name]

Custom dir and name

  • Windows: %APPDATA%\[custom_user_dir_name]
  • macOS: ~/Library/Application Support/[custom_user_dir_name]
  • Linux: ~/.local/share/[custom_user_dir_name]

Converting paths to absolute paths or "local" paths

You can use ProjectSettings.globalize_path() to convert a "local" path like res://path/to/file.txt to an absolute OS path. For example, ProjectSettings.globalize_path() can be used to open "local" paths in the OS file manager using OS.shell_open() since it only accepts native OS paths.

To convert an absolute OS path to a "local" path starting with res:// or user://, use ProjectSettings.localize_path(). This only works for absolute paths that point to files or folders in your project's root or user:// folders.

Editor data paths

The editor uses different paths for editor data, editor settings, and cache, depending on the platform. By default, these paths are:

Type

Location

Editor data

  • Windows: %APPDATA%\Godot\
  • macOS: ~/Library/Application Support/Godot/
  • Linux: ~/.local/share/godot/

Editor settings

  • Windows: %APPDATA%\Godot\
  • macOS: ~/Library/Application Support/Godot/
  • Linux: ~/.config/godot/

Cache

  • Windows: %TEMP%\Godot\
  • macOS: ~/Library/Caches/Godot/
  • Linux: ~/.cache/godot/
  • Editor data - contains export templates and project-specific data.
  • Editor settings - contains the main editor settings configuration file as well as various other user-specific customizations (editor layouts, feature profiles, script templates, etc.).
  • Cache - contains data generated by the editor, or stored temporarily. It can safely be removed when Godot is closed.

Meaning of the delta value in Process

Because the frame rate may differ from one video frame to another, the time delay (delta) between frames is passed to the _process(delta) function. This is a float value of the number of seconds between frames, so it is likely to be around 0.0167 seconds.

In short:

extends Node2D

# Desired movement in pixels/second.

var movement = Vector2(120, 0)

func _process(delta):
    $Sprite.position += movement * delta

Examples

Root viewport

The root Viewport is always at the top of the scene. From a node, it can be included in two different ways:

GetTree().GetRoot(); // Access via scene main loop.
GetNode("/root"); // Access via absolute path.

Change scene

GetTree().ChangeScene("res://levels/level2.tscn");

Linking an already-created resource:

var nextScene = (PackedScene)ResourceLoader.Load("res://levels/level2.tscn");
GetTree().ChangeSceneTo(nextScene);

In 4.0, use the following.

var scene = ResourceLoader.Load("res://Slot.tscn") as PackedScene;
this.GetTree().ChangeSceneToPacked(scene);

Loading resources from code

var texture = (Texture)GD.Load("res://robi.png"); // Godot loads the Resource when it reads the line.
var sprite = (Sprite)GetNode("sprite");
sprite.Texture = texture;

Loading scenes

To get an instance of a scene, you must use the PackedScene.instance() method.

private PackedScene _bulletScene = (PackedScene)GD.Load("res://bullet.tscn");

public void OnShoot()
{
    Node bullet = _bulletScene.Instance();
    AddChild(bullet);
}

Reloading the scene

GetTree().ReloadCurrentScene();

Removing a scene

var root = GetNode("/root");
var level = GetNode("level");
root.RemoveChild(level)
level.CallDeferred("free")

Alternatively, the QueueFree() function removes it safely.

Getting the screen size

// you can find the size of viewport using this:
GetViewport().GetRect().Size
GetViewportRect().Size

// or you can find the windows_size by
OS.GetWindowsSize()

Resizing the scene to the screen size

using Godot;
using System;

public class LoginUI : Panel
{
    public override void _Ready()
    {
        SetSize(GetViewportRect().Size);
    }
}

Printing log messages

GD.Print("Hello, World!");

Quit

GetTree().Quit();

Troubleshooting

Black screen when running after exporting the package (Export)

This can happen if no start scene is selected. Select Main Scene in Project Settings > General > Application > Run.

Child Scene not removed properly when removing it from an outer Scene

Assume the following scene.

Godot_Area2D_troubleshooting_screenshot_1.png

Another scene can instantiate and use the scene above as follows.

using Godot;
using System;
using System.Collections.Generic;

public class Piano : Node2D
{
    private PackedScene _eight_note = GD.Load<PackedScene>("res://EighthNote.tscn");
    private Random _random_device = new Random();

    // ...

    private void _on_Timer_timeout()
    {
        EighthNote note = _eight_note.Instance() as EighthNote;
        GD.Print("Create new Sprite " + note.ToString() + " ins id: (" + note.GetInstanceId() + ")!!");
        AddChild(note);

        int line_height = _random_device.Next(0, 5);
        note.Position = new Vector2(GetViewportRect().Size.x, 470 - (line_height*8));
        note.Scale = new Vector2(0.2f, 0.2f);
    }
}

The problem: in certain events (e.g. the area_exited signal of Area2D), the Child Node is received as the event object, and in this case removing the object passed by the event with QueueFree does not remove it properly.

    private void _on_Area2D_area_exited(Area2D area)
    {
        area.QueueFree();
    }

In this case, as shown in the figure below, changing the object received by the event to the topmost (Root) object makes removal work properly.

Godot_Area2D_troubleshooting_screenshot_2.png

=== .NETFramework,Version=v4.7.2 were not found ===

The following error may be printed.

Project "EduPiano.sln" (Restore target(s)):
    Message: Building solution configuration "Debug|Any CPU".
    Project "EduPiano.csproj" (_IsProjectRestoreSupported target(s)):
    Done building project "EduPiano.csproj".
    NuGetMessageTask: Determining projects to restore...
    Project "EduPiano.csproj" (_GenerateRestoreProjectPathWalk target(s)):
    Done building project "EduPiano.csproj".
    Project "EduPiano.csproj" (_IsProjectRestoreSupported target(s)):
    Done building project "EduPiano.csproj".
    Project "EduPiano.csproj" (_GenerateRestoreGraphProjectEntry target(s)):
    Done building project "EduPiano.csproj".
    Project "EduPiano.csproj" (_GenerateProjectRestoreGraph target(s)):
    Done building project "EduPiano.csproj".
    RestoreTask: Committing restore...
    RestoreTask: Assets file has not changed. Skipping assets file writing. Path: /home/your/Project/EduPiano/.mono/temp/obj/project.assets.json
    RestoreTask: Restored /home/your/Project/EduPiano/EduPiano.csproj (in 41 ms).
    RestoreTask: 
    RestoreTask: NuGet Config files used:
    RestoreTask:     /home/your/.nuget/NuGet/NuGet.Config
    RestoreTask: 
    RestoreTask: Feeds used:
    RestoreTask:     https://api.nuget.org/v3/index.json
    RestoreTask: All projects are up-to-date for restore.
Done building project "EduPiano.sln".
Project "EduPiano.sln" (Build target(s)):
    Message: Building solution configuration "Debug|Any CPU".
    Project "EduPiano.csproj" (default targets):
        /usr/share/dotnet/sdk/5.0.104/Microsoft.Common.CurrentVersion.targets(1180,5): error MSB3644: The reference assemblies for .NETFramework,Version=v4.7.2 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/home/your/Project/EduPiano/EduPiano.csproj]
    Done building project "EduPiano.csproj" -- FAILED.
Done building project "EduPiano.sln" -- FAILED.

For 3.2.3, you can add the following property inside the PropertyGroup of the csproj:

<GodotUseNETFrameworkRefAssemblies>true</GodotUseNETFrameworkRefAssemblies>

Unhandled Exception: System.TypeLoadException: Could not resolve type with token

Unhandled Exception: System.TypeLoadException: Could not resolve type with token 0100003b

Check that the TargetFrameworks value in the .csproj file matches the version for the distributed build. For reference, the Godot 3.2.3.stable.mono version uses net472.

System.UnauthorizedAccessException

When using the mono version of godot, if an error like System.UnauthorizedAccessException: Access to the path {...} is denied occurs

Check the permissions in the AndroidManifest.xml file:

<manifest ...>
    ...
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    ...
    <application android:requestLegacyExternalStorage="true" ...>
    ...
    </application>
    ...
</manifest>

When using a class like System.IO.FileStream, omitted arguments can end up requesting unwanted permissions as well. Always specify all permissions explicitly.

var fileStream = new FileStream(file, FileMode.Open)

Specify the FileAccess.Read parameter as well, as follows.

var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read)

Type Error

When the code is written like this,

var sprite = GetNode<AnimationSprite>("Tree/Tree1");

if a Type error occurs even though the code has no problems, try adding Godot as follows.

var sprite = GetNode<Godot.AnimationSprite>("Tree/Tree1");

Mono AOT compiler exited

When exporting a package to iOS, the message above is printed with exit code 1. See XCode#NSPOSIXErrorDomain: Operation not permitted.

As an aside, also see .NET Core.

Not working GD.Print method

If GD.Print()-related functions do not work, check whether the subprojects or script files are properly placed in the solution or project file ([Project].sln, [Project].csproj).

Android APK installation error

If you add resource files that are not registered to the godot project directory, the Android APK does not install properly.

Console logs not printed after Android Remote Debugging

Check the checkbox of the Debug > Deploy with Remote Debug menu.

Godot-debug-deploy_with_remote_debug.png

Unsupported class file major version 61

See Gradle#Unsupported class file major version 61.

'jarsigner' returned with error #1

See Godot:Export:Android#'jarsigner' returned with error #1.

HUD moves along when the screen (camera) moves

Add the GUI nodes as child nodes of a new Godot:CanvasLayer.

See also

Favorite site

Tutorials

Guide

References

author Zer0 sitemap