Work in progress

The content of this page was not yet updated for Godot 4.2 and may be outdated. If you know how to improve this page or you can confirm that it's up to date, feel free to open a pull request.

Scripting languages

이 강의에서는 Godot에서 사용할 수 있는 스크립트 언어들을 살펴볼 것입니다. 옵션 별로 어떤 장점과 단점이 있는지 배워봅시다. 그 다음, GDScript를 사용하여 첫 번째 스크립트를 작성해 보겠습니다.

스크립트는 노드에 연결되어 노드의 동작을 확장합니다. 이는 스크립트가 연결된 노드의 모든 기능과 속성을 상속한다는 의미입니다.

Camera2D 노드가 배를 따라가는 게임을 예로 들어봅시다. Camera2D 노드는 기본적으로 상위 노드를 따릅니다. 플레이어가 피해를 입을 때 카메라가 흔들리기를 원한다고 상상해 봅시다. 이 기능은 Godot에 내장되어 있지 않으므로, Camera2D 노드에 스크립트를 연결하고 흔들림을 코딩하면 됩니다.

../../_images/scripting_camera_shake.gif

Available scripting languages

Godot offers four gameplay programming languages: GDScript, C#, and, via its GDExtension technology, C and C++. There are more community-supported languages, but these are the official ones.

You can use multiple languages in a single project. For instance, in a team, you could code gameplay logic in GDScript as it's fast to write, and use C# or C++ to implement complex algorithms and maximize their performance. Or you can write everything in GDScript or C#. It's your call.

우리는 다양한 게임 프로젝트와 개발자의 요구에 부응하기 위해 다양한 선택지를 제공합니다.

Which language should I use?

초보자라면 **GDScript로 시작하기**를 권장합니다. GDScript는 Godot와 게임 개발자의 요구를 위해 특별히 만들어진 언어입니다. GDScript는 가볍고, 문법이 직관적이며 Godot와 가장 긴밀하게 통합되어 있습니다.

../../_images/scripting_gdscript.png

C#의 경우 VSCode 또는 Visual Studio 등의 외부 코드 편집기가 필요합니다. C# 지원은 이제 성숙해졌지만 GDScript에 비해 학습 리소스가 더 적습니다. 그렇기 때문에 우리는 이미 언어 경험이 있는 사용자에게 주로 C#을 권장합니다.

각 언어의 특징과 장단점을 살펴보겠습니다.

GDScript

:ref:`GDScript<doc_gdscript>`는 Godot용으로 만들어진`객체 지향 <https://en.wikipedia.org/wiki/Object- Oriented_programming>`_이자 `명령형 <https://en.wikipedia.org/wiki/ Imperative_programming>`_ 프로그래밍 언어입니다. GDScript는 게임 코딩 시간을 단축하기 위해 게임 개발자에 의해, 게임 개발자를 위해 만들어졌습니다. 그 기능은 다음과 같습니다:

  • 파일을 짧게 만드는 간단한 구문.

  • 엄청나게 빠른 컴파일 및 로딩 시간.

  • Tight editor integration, with code completion for nodes, signals, and more information from the scene it's attached to.

  • Built-in vector and transform types, making it efficient for heavy use of linear algebra, a must for games.

  • Supports multiple threads as efficiently as statically typed languages.

  • 게임을 만들 때 방해가 되는 `가비지 컬렉션<https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)>`_없음. 엔진은 대부분의 경우 기본적으로 참조를 계산하고 메모리를 관리하지만 필요한 경우 메모리를 제어할 수도 있음.

  • 점진적 타이핑. 변수에는 기본적으로 동적 유형이 있지만 강력한 유형 검사를 위해 유형 힌트 사용 가능.

GDScript의 코드 블록은 들여쓰기를 사용해 Python처럼 보이지만, 동일한 방식으로 동작하는 건 아닙니다. GDScript는 Squirrel, Lua, Python을 포함한 여러 언어에서 영감을 받았습니다.

참고

그냥 Python이나 Lua를 사용하면 안될까요?

몇 년 전, Godot는 Python을 사용했고 이후 Lua를 사용했습니다. 두 언어의 통합에는 많은 작업이 필요했고 심각한 제한이 있었습니다. 예를 들어, 스레딩 지원은 Python의 큰 과제였습니다.

전용 언어를 개발하는 것은 이보다 더 많은 작업이 필요하지 않으며 게임 개발자의 요구에 맞게 조정도 할 수 있습니다. 이제 우리는 서드파티 언어로는 제공하기 어려웠던 성능 최적화 및 기능을 개발 중입니다.

.NET / C#

As Microsoft's C# is a favorite amongst game developers, we officially support it. C# is a mature and flexible language with tons of libraries written for it. We were able to add support for it thanks to a generous donation from Microsoft.

../../_images/scripting_csharp.png

C# offers a good tradeoff between performance and ease of use, although you should be aware of its garbage collector.

참고

You must use the .NET edition of the Godot editor to script in C#. You can download it on the Godot website's download page.

Since Godot uses .NET 6, in theory, you can use any third-party .NET library or framework in Godot, as well as any Common Language Infrastructure-compliant programming language, such as F#, Boo, or ClojureCLR. However, C# is the only officially supported .NET option.

참고

GDScript 코드 자체는 컴파일 된 C# 또는 C++만큼 빠르게 실행되지 않습니다. 그러나 대부분의 스크립트 코드는 엔진 내부에서 C++ 코드로 빠른 알고리즘으로 작성된 함수를 호출합니다. 대부분의 경우 GDScript, C# 또는 C++로 게임플레이 로직을 작성해도 성능에 큰 영향을 미치지 않습니다.

주의

Projects written in C# using Godot 4 currently cannot be exported to the web platform. To use C# on that platform, consider Godot 3 instead. Android and iOS platform support is available as of Godot 4.2, but is experimental and some limitations apply.

C++ via GDExtension

GDExtension allows you to write game code in C++ without needing to recompile Godot.

../../_images/scripting_cpp.png

You can use any version of the language or mix compiler brands and versions for the generated shared libraries, thanks to our use of an internal C API Bridge.

GDExtension is the best choice for performance. You don't need to use it throughout an entire game, as you can write other parts in GDScript or C#.

When working with GDExtension, the available types, functions, and properties closely resemble Godot's actual C++ API.

요약

스크립트는 노드의 기능을 확장하기 위해 연결하는 코드가 포함된 파일입니다.

Godot supports four official scripting languages, offering you flexibility between performance and ease of use.

예를 들어, C 또는 C++로 까다로운 알고리즘을 구현하고 그 외 대부분의 게임 로직을 GDScript 또는 C#으로 작성하는 식으로 여러 언어를 사용할 수 있습니다.