Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

常见问题

可以用 Godot 做什么?需要花多少钱?有哪些许可条款?

Godot is Free and open source Software available under the OSI-approved MIT license. This means it is free as in "free speech" as well as in "free beer."

简而言之:

  • 你可以自由下载和使用 Godot,用于个人、非营利、商业等任何目的。

  • 无论出于任何原因,商业还是非商业,您都可以根据自己的心之所向,自由地对 Godot 进行修改、分发、再分发、改版。

All the contents of this accompanying documentation are published under the permissive Creative Commons Attribution 3.0 (CC BY 3.0) license, with attribution to "Juan Linietsky, Ariel Manzur and the Godot Engine community."

Logo 徽标和图标均在相同的 CC 共享许可下。注意,Godot 的源代码中包含的某些第三方库可能具有不同的许可。

有关详细信息,请查看 Godot 仓库中的 COPYRIGHT.txt 以及 LICENSE.txtLOGO_LICENSE.txt 文件。

还可以查阅 Godot 网站上的许可页面

Godot 支持哪些平台?

编辑器:

  • Windows

  • macOS

  • Linux, *BSD

  • Android(实验性)

  • Web (experimental)

导出游戏:

  • Windows(以及 UWP)

  • macOS

  • Linux, *BSD

  • Android

  • iOS

  • Web

Both 32- and 64-bit binaries are supported where it makes sense, with 64 being the default. Official macOS builds support Apple Silicon natively as well as x86_64.

一些用户也在 Linux 的基于 ARM 的系统上成功构建和使用 Godot,如树莓派。

The Godot team can't provide an open source console export due to the licensing terms imposed by console manufacturers. Regardless of the engine you use, though, releasing games on consoles is always a lot of work. You can read more about Godot 的游戏主机支持.

有关这方面的更多信息,请参阅导出编译 Godot 章节。

Godot 支持哪些编程语言?

The officially supported languages for Godot are GDScript, C#, and C++. See the subcategories for each language in the scripting section.

如果你刚开始接触 Godot 或一般的游戏开发,推荐学习并使用 GDScript 语言,因为它是 Godot 的原生语言。虽然从长远来看,脚本语言的性能往往不如低级语言,但对于原型设计、开发最小可行产品(MVP)和关注上市时间(TTM)来说,GDScript 将提供一种快速、友好、有能力的游戏开发方式。

Note that C# support is still relatively new, and as such, you may encounter some issues along the way. C# support is also currently missing on Android, iOS and web platforms. Our friendly and hard-working development community is always ready to tackle new problems as they arise, but since this is an open source project, we recommend that you first do some due diligence yourself. Searching through discussions on open issues is a great way to start your troubleshooting.

As for new languages, support is possible via third parties with GDExtensions. (See the question about plugins below). Work is currently underway, for example, on unofficial bindings for Godot to Python and Nim.

GDScript 是什么?为什么要用它?

GDScript is Godot's integrated scripting language. It was built from the ground up to maximize Godot's potential in the least amount of code, affording both novice and expert developers alike to capitalize on Godot's strengths as fast as possible. If you've ever written anything in a language like Python before, then you'll feel right at home. For examples and a complete overview of the power GDScript offers you, check out the GDScript scripting guide.

There are several reasons to use GDScript, especially when you are prototyping, in alpha/beta stages of your project, or are not creating the next AAA title. The most salient reason is the overall reduction of complexity.

The original intent of creating a tightly integrated, custom scripting language for Godot was two-fold: first, it reduces the amount of time necessary to get up and running with Godot, giving developers a rapid way of exposing themselves to the engine with a focus on productivity; second, it reduces the overall burden of maintenance, attenuates the dimensionality of issues, and allows the developers of the engine to focus on squashing bugs and improving features related to the engine core, rather than spending a lot of time trying to get a small set of incremental features working across a large set of languages.

Since Godot is an open source project, it was imperative from the start to prioritize a more integrated and seamless experience over attracting additional users by supporting more familiar programming languages, especially when supporting those more familiar languages would result in a worse experience. We understand if you would rather use another language in Godot (see the list of supported options above). That being said, if you haven't given GDScript a try, try it for three days. Just like Godot, once you see how powerful it is and rapid your development becomes, we think GDScript will grow on you.

有关熟悉 GDScript 或动态类型语言的更多信息,请参阅 GDScript:动态语言简介 教程。

创建 GDScript 背后的动机是什么?

In the early days, the engine used the Lua scripting language. Lua can be fast thanks to LuaJIT, but creating bindings to an object-oriented system (by using fallbacks) was complex and slow and took an enormous amount of code. After some experiments with Python, that also proved difficult to embed.

为 Godot 创建自定义脚本语言的主要原因有:

  1. Godot 使用多线程,而大多数脚本虚拟机对线程的支持不佳(Lua、Python、Squirrel、JavaScript、ActionScript 等)。

  2. 大多数脚本语言(Lua、Python、JavaScript)的虚拟机没有很好地支持类扩展,适配 Godot 工作方式的效率极低。

  3. Many existing languages have horrible interfaces for binding to C++, resulting in a large amount of code, bugs, bottlenecks, and general inefficiency (Lua, Python, Squirrel, JavaScript, etc.). We wanted to focus on a great engine, not a great number of integrations.

  4. 没有原生的向量类型(vector3、matrix4 等),导致使用自定义类型实现时,性能大大降低(Lua、Python、Squirrel、JavaScript、ActionScript 等)。

  5. 在大部分解释型编程语言(Lua、Python、JavaScript、ActionScript 等)中,垃圾收集器会导致延迟或不必要的大内存使用。

  6. Difficulty integrating with the code editor for providing code completion, live editing, etc. (all of them).

GDScript 是为了减少上述问题以及防止更多问题而设计的。

What 3D model formats does Godot support?

You can find detailed information on supported formats, how to export them from your 3D modeling software, and how to import them for Godot in the 导入 3D 场景 documentation.

Godot 会支持【此处插入 FMOD、GameWorks 等闭源 SDK 的名字】吗?

The aim of Godot is to create a free and open source MIT-licensed engine that is modular and extendable. There are no plans for the core engine development community to support any third-party, closed-source/proprietary SDKs, as integrating with these would go against Godot's ethos.

That said, because Godot is open source and modular, nothing prevents you or anyone else interested in adding those libraries as a module and shipping your game with them, as either open- or closed-source.

如欲了解如何支持您使用的 SDK,请查看下面的插件问题。

If you know of a third-party SDK that is not supported by Godot but that offers free and open source integration, consider starting the integration work yourself. Godot is not owned by one person; it belongs to the community, and it grows along with ambitious community contributors like you.

如何在我的系统上安装 Godot 编辑器(进行桌面集成)?

Godot 实际并不需要在你的系统上进行安装就能够运行,因此不会自动进行桌面集成。解决方法有两种。你可以通过 Steam(全平台)、Scoop(Windows)、Homebrew(macOS)、Flathub(Linux)来安装 Godot。这样就会自动执行桌面集成所需的步骤。

另外你也可以手动执行安装文件会帮你执行的步骤:

Windows

  • 将 Godot 可执行文件移动到稳定的位置(即你的 Downloads 文件夹之外),这样你以后就不会不小心对它进行移动、不会破坏快捷方式了。

  • 右键单击 Godot 可执行文件,选择创建快捷方式

  • Move the created shortcut to %APPDATA%\Microsoft\Windows\Start Menu\Programs. This is the user-wide location for shortcuts that will appear in the Start menu. You can also pin Godot in the task bar by right-clicking the executable and choosing Pin to Task Bar.

macOS

将解压出的 Godot 应用拖拽至 /Applications/Godot.app,如果需要的话还可以再拖到 Dock 栏上。只要 Godot 在 /Applications~/Applications 中,“聚焦”就能找到它。

Linux

  • 将 Godot 二进制文件移动到稳定的位置(即你的 Downloads 文件夹之外),这样你以后就不会不小心对它进行移动、不会破坏快捷方式了。

  • 将 Godot 二进制文件进行重命名,然后移动到处于 PATH 环境变量中的某个位置。通常是 /usr/local/bin/godot 或者 /usr/bin/godot。这个操作需要管理员权限,不过能够让你通过输入 godot 直接从命令行运行 Godot 编辑器

    • 如果你无法将 Godot 编辑器二进制文件移动到受保护的位置,你可以将它保存在你的家目录中的某个位置,然后修改下方链接的 .desktop 文件中的 Path= 行,让它包含指向 Godot 二进制文件的完整绝对路径。

  • Save this .desktop file to $HOME/.local/share/applications/. If you have administrator privileges, you can also save the .desktop file to /usr/local/share/applications to make the shortcut available for all users.

Godot 编辑器是绿色应用吗?

默认配置下,Godot 是半绿色的。从任何位置运行都可以运行它的可执行文件(包括无法写入的位置),无须管理员权限。

不过,配置文件会写入到针对用户的配置或数据目录。通常来说,这是不错的做法,但也意味着将包含 Godot 可执行文件的文件夹复制到另一台机器上是无法带走配置文件的。更多信息请参阅 Godot 项目中的文件路径

如果你需要真·绿色的操作(例如放到 U 盘上使用),请按照 自包含模式 中的步骤操作。

为什么 Godot 使用 Vulkan/OpenGL 而不是 Direct3D?

Godot aims for cross-platform compatibility and open standards first and foremost. OpenGL and Vulkan are the technologies that are both open and available on (nearly) all platforms. Thanks to this design decision, a project developed with Godot on Windows will run out of the box on Linux, macOS, and more.

由于 Godot 只有少数人在处理其渲染器,因此我们希望维护较少的渲染后端。最重要的是,在所有平台上使用单个 API 可以提高一致性,减少特定于平台的问题。

In the long term, we may develop a Direct3D 12 renderer for Godot (mainly for Xbox), but Vulkan and OpenGL will remain the default rendering backends on all platforms, including Windows.

为什么 Godot 旨在保持其核心功能集较小?

Godot intentionally does not include features that can be implemented by add-ons unless they are used very often. One example of something not used often is advanced artificial intelligence functionality.

这有几个原因:

  • Code maintenance and surface for bugs. Every time we accept new code in the Godot repository, existing contributors often take the responsibility of maintaining it. Some contributors don't always stick around after getting their code merged, which can make it difficult for us to maintain the code in question. This can lead to poorly maintained features with bugs that are never fixed. On top of that, the "API surface" that needs to be tested and checked for regressions keeps increasing over time.

  • 易于贡献。通过保持代码库小而整洁, 可以保持快速、轻松地从源代码编译。这使得新贡献者更容易入门 Godot,无需他们购买高端硬件。

  • 为编辑器保持较小的二进制大小。并非每个人都拥有快速的 Internet 连接。确保每个人都可以在 5 分钟内下载、解压缩并运行 Godot 编辑器,这使得所有国家/地区的开发人员都可以更轻松地访问 Godot。

  • Keeping the binary size small for export templates. This directly impacts the size of projects exported with Godot. On mobile and web platforms, keeping file sizes low is important to ensure fast installation and loading on underpowered devices. Again, there are many countries where high-speed Internet is not readily available. To add to this, strict data usage caps are often in effect in those countries.

基于上述原因,我们必须选择哪些功能作为 Godot 的核心功能。这就是为什么我们计划在 Godot 的未来版本里,将转移一些核心功能到官方支持的附加组件中。在文件大小方面,这也算是一个优点,你的项目可以精简掉没有实际使用过的功能(目前,你可以通过编译自定义导出模板、禁用未使用的功能来优化项目的发布大小。)

如果要适配多种分辨率和纵横比,资产应做哪些处理?

这个问题很常见,可能要归功于苹果公司。苹果一开始将它们的设备分辨率加倍,让人觉得不同分辨率使用相同的资产是个好主意,所以很多人就这么做下去了。起初只有苹果设备这么做,但 Android 和后来的苹果设备又有了不同的分辨率和宽高比,它们的大小和 DPI 变得多种多样。

最常见和最恰当的处理方法是,为游戏使用单一基本分辨率,并仅处理不同的屏幕宽高比。主要是 2D 游戏需要这么做,在 3D 游戏中它只是相机 XFov 或 YFov 的问题。

  1. Choose a single base resolution for your game. Even if there are devices that go up to 2K and devices that go down to 400p, regular hardware scaling in your device will take care of this at little or no performance cost. The most common choices are either near 1080p (1920x1080) or 720p (1280x720). Keep in mind the higher the resolution, the larger your assets, the more memory they will take and the longer the time it will take for loading.

  2. 使用 Godot 中的拉伸选项;2D 保持宽高比时拉伸效果最好。请参阅教程 多分辨率 来学习如何实现。

  3. 确定最小分辨率,然后决定是否希望游戏垂直或水平拉伸以获得不同的宽高比,或者如果有一个宽高比并且您希望显示黑条。这也在 多分辨率 中有所解释。

  4. 对于用户界面,请使用 锚定 来确定控件应停留和移动的位置。如果 UI 更复杂,请考虑学习 Container(容器)。

就是这样!你的游戏应该能够以多种分辨率运行了。

如果希望让您的游戏也适用于具有小屏幕(宽度小于 300 像素)的古老设备,可以在导出选项中缩小图像,并且在 App Store 或 Google Play 中将它设为用于特定的屏幕大小。

如何扩展 Godot?

要扩展 Godot,比如创建 Godot 编辑器插件或添加对其他语言的支持,请参阅编辑器插件和工具脚本。

Also, see the official blog post on GDExtension, a way to develop native extensions for Godot:

您还可以查看 GDScript 的实现,Godot 模块以及 Godot 的非官方 Python 支持。这个将是您了解如何将第三方库整合到 Godot 中的第一步。

Godot 的下一个版本什么时候发布?

当它准备好的时候!详情见 在编辑器中运行代码

Which Godot version should I use for a new project?

We recommend using Godot 4.x for new projects, but depending on the feature set you need, it may be better to use 3.x instead. See Which version should I use for a new project? for more information.

Should I upgrade my project to use new Godot versions?

Some new versions are safer to upgrade to than others. In general, whether you should upgrade depends on your project's circumstances. See Should I upgrade my project to use new engine versions? for more information.

我想要贡献! 该如何开始?

Awesome! As an open source project, Godot thrives off of the innovation and the ambition of developers like you.

The best way to start contributing to Godot is by using it and reporting any issues that you might experience. A good bug report with clear reproduction steps helps your fellow contributors fix bugs quickly and efficiently. You can also report issues you find in the online documentation.

If you feel ready to submit your first PR, pick any issue that resonates with you from one of the links above and try your hand at fixing it. You will need to learn how to compile the engine from sources, or how to build the documentation. You also need to get familiar with Git, a version control system that Godot developers use.

We explain how to work with the engine source, how to edit the documentation, and what other ways to contribute are there in our documentation for contributors.

我有个关于 Godot 的好主意,该如何分享它?

We are always looking for suggestions about how to improve the engine. User feedback is the main driving force behind our decision-making process, and limitations that you might face while working on your project are a great data point for us when considering engine enhancements.

If you experience a usability problem or are missing a feature in the current version of Godot, start by discussing it with our community. There may be other, perhaps better, ways to achieve the desired result that community members could suggest. And you can learn if other users experience the same issue, and figure out a good solution together.

If you come up with a well-defined idea for the engine, feel free to open a proposal issue. Try to be specific and concrete while describing your problem and your proposed solution — only actionable proposals can be considered. It is not required, but if you want to implement it yourself, that's always appreciated!

If you only have a general idea without specific details, you can open a proposal discussion. These can be anything you want, and allow for a free-form discussion in search of a solution. Once you find one, a proposal issue can be opened.

Please, read the readme document before creating a proposal to learn more about the process.

是否能用 Godot 创建非游戏应用?

是的!Godot 具有广泛的内置 UI 系统,其较小的软件包可以使它成为 Electron 或 Qt 等框架的合适替代品。

当创建一个非游戏的应用程序时,确保在项目设置中启用 低处理器模式 以减少CPU和GPU占用。

也就是说,我们不建议使用 Godot 来创建移动应用程序,因为移动平台还不支持低处理器模式。

请查看 Material MakerPixelorama,以了解用 Godot 制作的开源应用程序的例子。

是否能将 Godot 作为库使用?

Godot 旨在与其编辑器一起使用。我们建议您尝试一下编辑器,因为从长远来看,它很可能会节省您的时间。目前尚无计划把 Godot 作为库使用,因为这会使引擎的其余部分更加混乱,难以为普通用户使用。

如果你想使用一个渲染库,那就使用一个已经建立的渲染引擎来代替。需要注意的是,与 Godot 相比,渲染引擎通常拥有更小的社区,这将会使你解决问题的难度加大。

Godot 使用的用户界面工具包是什么?

Godot 不使用标准的 GUI 工具箱,如 GTK、Qt 或 wxWidgets。相反,Godot 使用自己的用户界面工具包,使用 OpenGL ES 或 Vulkan 进行渲染。这个工具包以控件节点(Control)的形式暴露出来,用于渲染编辑器(用 C++ 编写)。这些控制节点也可以在 Godot 支持的任何脚本语言的项目中使用。

这个定制的工具包使它能获益于硬件加速,并在全平台上拥有一致的外观。最重要的是,它不必处理 GTK 或 Qt 所带来的 LGPL 许可注意事项。最后,这意味着 Godot 在“自产自用”,因为编辑器本身就是 Godot UI 系统中最复杂的用例之一。

这个自定义 UI 工具包不能作为一个库使用,但你仍然可以通过使用 Godot 编辑器来创建非游戏应用程序

Why does Godot use the SCons build system?

Godot uses the SCons build system. There are no plans to switch to a different build system in the near future. There are many reasons why we have chosen SCons over other alternatives. For example:

  • Godot 可以针对多种不同的平台进行编译:所有 PC 平台、所有移动平台、各种游戏主机、WebAssembly。

  • 开发者们经常需要同时将代码编译到多个平台上,或者同一个平台的不同架构上,但他们负担不起每次都要重新配置和重构项目。SCons 可以毫不费力地完成此任务,而不会破坏构建。

  • SCons will never break a build no matter how many changes, configurations, additions, removals etc.

  • Godot's build process is not simple. Several files are generated by code (binders), others are parsed (shaders), and others need to offer customization (modules). This requires complex logic which is easier to write in an actual programming language (like Python) rather than using a mostly macro-based language only meant for building.

  • Godot的构建过程大量使用了交叉编译工具. 每个平台都有特定的检测过程, 需为每个平台编写特殊代码, 将这些作为特殊情况处理.

Please try to keep an open mind and get at least a little familiar with SCons if you are planning to build Godot yourself.

为什么 Godot 不使用 STL(标准模板库)?

Like many other libraries (Qt as an example), Godot does not make use of STL. We believe STL is a great general-purpose library, but we had special requirements for Godot.

  • STL 模板会创建大量符号,产生巨型的调试二进制文件。我们使用一些名称很短的模板来代替。

  • 我们的大多数容器都是针对特定需求设计的,例如 Vector 使用写时复制,我们用它来传递数据,而 RID 系统则需要 O(1) 访问时间来提高性能。同样,我们的哈希表实现旨在与内部引擎类型无缝集成。

  • 我们的容器内置了内存跟踪,有助于更好地跟踪内存的使用情况。

  • 对于大型数组,我们使用内存池,可以映射到预先分配的缓冲区或虚拟内存。

  • 我们使用自定义字符串类型,因为 STL 提供的版本过于基础,并且缺乏适当的国际化支持。

为什么 Godot 不使用异常?

我们相信无论如何游戏都不应该崩溃。如果发生意外情况,Godot将打印一个错误(甚至可以追溯到脚本),但之后它会尽可能优雅地恢复,并继续前进。

Additionally, exceptions significantly increase the binary size for the executable.

为什么 Godot 不使用 RTTI?

Godot 提供了自己的类型转换系统,可以可选地在内部使用 RTTI(运行时类型识别)。在 Godot 中禁用 RTTI 意味着可以以较小的性能代价实现相当小的二进制大小。

Does Godot use an ECS (Entity Component System)?

Godot does not use an ECS and relies on inheritance instead. While there is no universally better approach, we found that using an inheritance-based approach resulted in better usability while still being fast enough for most use cases.

That said, nothing prevents you from making use of composition in your project by creating child Nodes with individual scripts. These nodes can then be added and removed at run-time to dynamically add and remove behaviors.

More information about Godot's design choices can be found in this article.

Why does Godot not force users to implement DOD (Data-Oriented Design)?

While Godot internally attempts to use cache coherency as much as possible, we believe users don't need to be forced to use DOD practices.

DOD is mostly a cache coherency optimization that can only provide significant performance improvements when dealing with dozens of thousands of objects which are processed every frame with little modification. That is, if you are moving a few hundred sprites or enemies per frame, DOD won't result in a meaningful improvement in performance. In such a case, you should consider a different approach to optimization.

绝大多数游戏都不需要这个, 并且Godot提供了方便的辅助工具来完成大多数情况下的工作.

If a game needs to process such a large amount of objects, our recommendation is to use C++ and GDExtensions for performance-heavy tasks and GDScript (or C#) for the rest of the game.

如何支持或参与 Godot 的发展?

请参阅 贡献方式

谁在为 Godot 工作?如何联系?

请参照 Godot 官网上的相应页面。