Skip to content

Godot

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

https://github.com/gdquest-demos 저장소에 있는 데모들

Dungeon Generation

Particle

Editors

Debug

Godot Compiling

  • 컴파일링(Compiling) — Godot Engine (stable) 문서 (한국어)
  • 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

다양한 해상도 지원 방법

How to install

Arch Linux

godot은 mono버전으로 AUR으로 설치한다.

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

또는 홈페이지의 mono 바이너리를 직접 설치하고 싶을 경우 아래의 종속성을 추가해야 한다.

$ sudo pacman -S mono dotnet-sdk msbuild

GNOME Desktop Icon

로고 svg는 홈페이지/다운로드 페이지1 에서 받을 수 있다. (직접 다운로드: Godot_logo.svg.zip)

~/.local/share/applications/godot.desktop 파일을 생성하고 아래 내용을 붙여넣으면 된다.

[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

외부 텍스트 에디터 연결하는 방법:

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

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.

Process 의 delta 값 의미

_process(delta) 함수는 모든 비디오 프레임중 다른 프레임 속도가있을 수 있으므로 프레임 간의 시간 지연 (델타)이 함수에 전달됩니다. 이것은 프레임 사이의 초 수의 부동 값이므로 약 0.0167 초가 될 가능성이 높습니다.

간단히:

extends Node2D

# Desired movement in pixels/second.

var movement = Vector2(120, 0)

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

Examples

루트 뷰포트(Root viewport)

루트 Viewport 는 항상 씬의 맨 위에 있습니다. 노드에서, 두 가지 다른 방법으로 포함할 수 있습니다:

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

Change scene

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

이미 만들어진 리소스 연결:

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

4.0 에서는 다음과 같이 사용하면 된다.

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

코드에서 리소스를 불러오기

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;

씬 불러오기

씬의 인스턴스를 얻기 위해, PackedScene.instance() 메서드를 사용해야 합니다.

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

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

씬 다시 불러오기

GetTree().ReloadCurrentScene();

씬 제거하기

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

또는 QueueFree() 함수를 쓰면 안정적으로 제거할 수 있다.

화면 크기 구하기

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

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

화면 크기에 맞춰 씬 크기 변경

using Godot;
using System;

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

로그 메시지 출력

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

종료

GetTree().Quit();

Troubleshooting

패키지 배포(Export) 후, 실행하면 화면이 검게 나타나는 현상

시작씬을 선택하지 않아서 그럴수 있다. Project Settings > General > Application > Run 에서 Main Scene을 선택하면 된다.

외부 Scene 에서 Child Scene 제거시 정상적으로 제거되지 않는 현상

다음과 같은 씬이 있다고 가정한다.

Godot_Area2D_troubleshooting_screenshot_1.png

다른 씬에서 위의 씬을 다음과 같이 인스턴스화 해서 사용할 수 있다.

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);
    }
}

문제는, 특정 이벤트 (e.g. Area2D의 area_exited 신호) 에서 Child Node 를 이벤트 객체로 획득하는데, 이경우 이벤트에서 넘겨진 객체를 QueueFree를 사용하여 제거해도 정상적으로 제거되지 않는다.

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

이 경우 아래 그림과 같이, 이벤트로 받을 객체를 최상단(Root) 객체로 변경하면 정상적으로 제거된다.

Godot_Area2D_troubleshooting_screenshot_2.png

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

다음과 같은 에러가 출력될 수 있다.

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.

3.2.3의 경우 csproj의 PropertyGroup 안에 다음 속성을 추가 할 수 있습니다:

<GodotUseNETFrameworkRefAssemblies>true</GodotUseNETFrameworkRefAssemblies>

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

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

.csproj파일에 TargetFrameworks 값이 배포버전에 해당하는 버전에 맞는지 확인하면 된다. 참고로, Godot 3.2.3.stable.mono 버전에서는 net472를 사용한다.

System.UnauthorizedAccessException

mono버전 godot을 사용할 경우 System.UnauthorizedAccessException: Access to the path {...} is denied 와 같은 에러가 발생될 경우

AndroidManifest.xml 파일의 권한 확인:

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

만약 System.IO.FileStream 같은 클래스를 사용할경우 생략된 인자를 통해 원치 않은 권한까지 전달될 수 있다. 반드시 모든 권한을 명시하자.

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

다음과 같이 FileAccess.Read 파라미터 까지 명시하자.

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

Type Error

다음과 같이 코딩했을 때,

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

코드상에서 문제가 없는데 Type 오류가 발생된다면, 다음과 같이 Godot을 추가해 보자.

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

Mono AOT compiler exited

iOS로 패키지 추출시 종료코드 1로 위 메시지가 출력된다. XCode#NSPOSIXErrorDomain: Operation not permitted 항목 참조.

번외로 .NET Core 항목도 참조.

Not working GD.Print method

GD.Print() 관련 함수가 작동하지 않을 경우, 혹시 솔루션 또는 프로젝트 파일 ([Project].sln, [Project].csproj) 에 하위 프로젝트 또는 스크립트 파일이 정상적으로 배치되었는지 확인해 보자.

Android APK 설치 에러

godot 프로젝트의 디렉토리에 등록되지 않은 리소스 파일을 추가하면 Android APK 가 정상적으로 설치되지 않는다.

Android Remote Debugging 이후 콘솔 로그가 출력되지 않는 현상

Debug > Deploy with Remote Debug 메뉴의 체크박스를 체크하면 된다.

Godot-debug-deploy_with_remote_debug.png

Unsupported class file major version 61

Gradle#Unsupported class file major version 61 항목 참조.

'jarsigner' returned with error #1

Godot:Export:Android#'jarsigner' returned with error #1 항목 참조.

화면 (카메라) 이동시 HUD 도 함께 이동하는 현상

GUI에 해당하는 노드를 새로운 Godot:CanvasLayer의 자식 노드로 추가하면 된다.

See also

Favorite site

Tutorials

Guide

References