Godot的设计理念

既然您已经小试身手,让我们谈谈Godot的设计。

Every game engine is different and fits different needs. Not only do they offer a range of features, but the design of each engine is unique. This leads to different workflows and different ways to form your games’ structures. This all stems from their respective design philosophies.

这个页面是为了帮助您通过godot的一些核心功能来理解它的工作原理。这个页面既不是godot特性的介绍列表,也不会对各个引擎做比较。要知道哪一种引擎更适合您的项目,您需要自己尝试一下并了解各个引擎对设计和局限性。

如果您正在寻找引擎特性的概述,请观看 探索免费游戏引擎Godot 3

面向对象的设计与组合

Godot凭借其灵活的场景系统和节点层次结构,将面向对象设计作为其核心。它试图远离严格的编程模式,以提供直观的方式来构建游戏。

首先,Godot可以让您 组合或聚合 场景。就像嵌套的预制件一样:您可以创建 BlinkingLight 场景,并创建使用 BlinkingLightBrokenLantern 场景。然后,创建一个充满 BrokenLanterns 的城市。更改BlinkingLight的颜色,保存,城市中的所有 BrokenLantern 都会立即更新。

最重要的是,您可以从任何场景 继承

A Godot scene could be a Weapon, a Character, an Item, a Door, a Level, part of a level… anything you’d like. It works like a class in pure code, except you’re free to design it by using the editor, using only the code, or mixing and matching the two.

It’s different from prefabs you find in several 3D engines, as you can then inherit from and extend those scenes. You may create a Magician that extends your Character. Modify the Character in the editor and the Magician will update as well. It helps you build your projects so that their structure matches the game’s design.

image0

Also note that Godot offers many different types of objects called nodes, each with a specific purpose. Nodes are part of a tree and always inherit from their parents up to the Node class. Although the engine does feature components like collision shapes, they’re the exception, not the norm.

image1

SpriteNode2DCanvasItemNode 类型。它具有三个父类的所有属性和特性,比如 transforms 或者绘制自定义形状和渲染自定义着色的能力。

全包

Godot尝试提供自己的工具来满足最常见的需求。它具有专用的脚本工作区、动画编辑器、tilemap编辑器、着色器编辑器、调试器、分析器、能够在本地和远程等设备上热重载的功能。

image2

我们的目标是提供一个完整的软件包来创建游戏以及持续的用户体验。您仍然可以和外部程序一起工作,只要有一个导入插件做支持。或者您可以自己创建一个,比如 Tiled Map导入器

That is also partly why Godot offers its own programming languages GDscript and VisualScript, along with C#. They’re designed for the needs of game developers and game designers, and they’re tightly integrated in the engine and the editor.

GDscript使您可以使用类似Python的语法编写简单的代码,但是它可以检测类型并提供静态语言的自动补全特质。它还针对具有内置类型(如 VectorsColors )的游戏代码进行了优化。

请注意,使用GDNative,您可以编写出使用类似C、C++、Rust或Python(使用Cython编译器)这类的编译语言编写的高性能代码,而无需重新编译引擎。

image3

VisualScript是一种基于节点的编程语言,可以很好地集成到编辑器中。 您可以将节点或资源拖放到图中以创建新的代码块。

Note that the 3D workspace doesn’t feature as many tools as the 2D workspace. You’ll need external programs or add-ons to edit terrains, animate complex characters, and so on. Godot provides a complete API to extend the editor’s functionality using game code. See The Godot editor is a Godot game below.

image4

Godube 2中的状态机编辑器插件,由kubecz3k开发。它使您可以直观地管理状态和转换。

开源

Godot offers a fully open source codebase under the MIT license. This means all the technologies that ship with it have to be Free (as in freedom) as well. For the most part, they’re developed from the ground up by contributors.

Anyone can plug in proprietary tools for the needs of their projects — they just won’t ship with the engine. This may include Google AdMob, or FMOD. Any of these can come as third-party plugins instead.

On the other hand, an open codebase means you can learn from and extend the engine to your heart’s content. You can also debug games easily, as Godot will print errors with a stack trace, even if they come from the engine itself.

注解

开放源码的协议不会以任何方式影响您用Godot所创作的作品:不会有附加条件影响Godot引擎与您用Godot制作的东西。

社区驱动

Godot is made by its community, for the community, and for all game creators out there. It’s the needs of the users and open discussions that drive the core updates. New features from the core developers often focus on what will benefit the most users first.

That said, although a handful of core developers work on it full-time, the project has over 600 contributors at the time of writing. Benevolent programmers work on features they may need themselves, so you’ll see improvements in all corners of the engine at the same time in every major release.

Godot编辑器是一个Godot游戏

The Godot editor runs on the game engine. It uses the engine’s own UI system, it can hot-reload code and scenes when you test your projects, or run game code in the editor. This means you can use the same code and scenes for your games, or build plugins and extend the editor.

由于它为编辑器本身提供了动力,因此这导致了可靠且灵活的UI系统。 使用 `` tool`` 关键字,您可以在编辑器中运行任何游戏代码。

image5

RPG in a Box is a voxel RPG editor made with Godot 2. It uses Godot’s UI tools for its node-based programming system and for the rest of the interface.

tool 关键字放在任何GDScript文件的顶部,它将在编辑器中运行。这使您可以导入和导出插件,创建自定义级别编辑器之类的插件,或使用与项目中使用的相同的节点和API来创建脚本。

独立的2D和3D引擎

Godot提供专门的2D和3D渲染引擎。因此,2D场景的基本单位是像素。 即使引擎是分开的,您可以在3D渲染2D,在2D渲染3D,并在您的3D世界叠加2D精灵和界面。