Godot 4 Game Development Cookbook - Jeff Johnson - E-Book

Godot 4 Game Development Cookbook E-Book

Jeff Johnson

0,0
28,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Explore the latest features of Godot 4 using advanced techniques and recipes to create professional-grade games with increased efficiency


Key Features


Take advantage of the new Vulkan renderer and 3D physics in Godot 4 to create high-quality games


Streamline your game development workflow with Godot’s new TileMap, TileSet, and Animation Editor features


Discover what’s changed in GDScript 2.0 and Shader additions to enhance your game development skills


Book Description


Want to transition from Godot 3 to 4? Look no further than the Godot 4 Game Development Cookbook. This comprehensive guide covers everything you need to become proficient with the latest GUI, GDscript 2.0, Vulkan 2D/3D rendering, shaders, audio, physics, TileSet/TileMap, importing, sound/music, animation, and multiplayer workflows. With its detailed recipes, the book leaves no stone unturned.


The Godot 4 Cookbook begins by exploring the updated graphical user interface and helps you familiarize yourself with the new features of GDscript 2.0. Next, it delves into the efficient rendering of 2D and 3D graphics using the Vulkan renderer. As it guides you in navigating the new Godot 4 platform, the book offers an in-depth understanding of shaders, including the latest enhancements to the shader language. Moreover, it covers a range of other topics, including importing from Blender, working with audio, and demystifying the new Vulkan Renderer and the physics additions for 2D and 3D. The book also shows you how the new changes to TileSet and TileMap make 2D game development easy. Advanced topics such as importing in Godot 4, adding sound and music to games, making changes in the Animation editor, and including workflows for multiplayer in Godot 4 are covered in detail.


By the end of this game development book, you’ll have gained a better understanding of Godot 4 and will be equipped with various powerful techniques to enhance your Godot game development efficiency.

What you will learn


Speed up 2D game development with new TileSet and TileMap updates


Improve 2D and 3D rendering with the Vulkan Renderer


Master the new animation editor in Godot 4 for advanced game development


Enhance visuals and performance with visual shaders and the updated shader language


Import Blender blend files into Godot to optimize your workflow


Explore new physics system additions for improved realism and behavior of game objects


Experience innovative features by building multiplayer games in Godot 4


Who this book is for


The Godot 4 Game Development Cookbook is for seasoned game developers who want to acquire skills in creating games using a contemporary game engine. It is an invaluable resource for indie game developers and Godot developers who are familiar with Godot 3 and have some level of expertise in maneuvering the interface.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 350

Veröffentlichungsjahr: 2023

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Godot 4 Game Development Cookbook

Over 50 solid recipes for building high-quality 2D and 3D games with improved performance

Jeff Johnson

BIRMINGHAM—MUMBAI

Godot 4 Game Development Cookbook

Copyright © 2023 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Rohit Rajkumar

Publishing Product Manager: Nitin Nainani

Content Development Editor: Abhishek Jadhav

Technical Editor: Simran Ali

Copy Editor: Safis Editing

Project Coordinator: Aishwarya Mohan

Proofreader: Safis Editing

Indexer: Manju Arasan

Production Designer: Nilesh Mohite

Marketing Coordinator: Nivedita Pandey

First published: June 2023

Production reference: 1100523

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-83882-607-9

www.packtpub.com

To Juan Linietsky and Ariel Manzur for creating Godot.

Contributors

About the author

Jeff Johnson is a game developer who started using Unity 4.0 in 2014 and released a couple of games on itch.io. In 2018, he created 999 Dev Studio. Toward the end of developing Escape from 51, he changed engines to Godot 3.0.2. He ported over almost the whole game to Godot from Unity. He released Escape from 51 on itch.io, as well as some mobile games on Google Play, all made with Godot.

About the reviewers

Yogendra Manawat is a bachelor’s student in computer science. He is an indie game developer and a product designer. Though he primarily learned development skills, he has acquired knowledge in programming languages such as C++, Python, C#, and GDScript.

Yogendra’s interest in games and movies led him to start making 3D animation with Blender, and he continues to work on game development projects while also contributing to the Godot Engine community.

With over three years of experience in game development, Yogendra has developed multiple small games and is currently focused on creating his original RPG game, TALKAD, using the Godot Engine. He continuously learns about new technologies and experiments with different game development techniques to create unique and engaging games. Yogendra is also an active participant in game development forums and communities, where he exchanges ideas and collaborates with other game developers.

Simon Dalvai is a free and open source game developer from Italy. You can find the source code for his games, such as Ball2Box and Pocket Broomball, on GitHub under the username dulvui. As a solo developer, Simon enjoys automating repetitive tasks, including taking screenshots and exporting and uploading games to publishing platforms with scripts and CI/CD tools such as GitHub Actions.

He learned to program in school and is currently working full-time as a software architect. Simon taught himself game development and has created games in his free time since 2018. He follows a strict policy of not including ads or user tracking in his games.

Initially, he used libGDX to develop his first games but switched to the Godot Engine in 2019.

Daniel Fulton has been a professional programmer since 2011. He has worked on a wide variety of iOS apps and games.

He has given tech talks on augmented reality, 3D game programming in SceneKit, software architecture, image performance, test-driven development, and readable code.

His hobbies include building games in Godot, Unity, and Unreal Engine, tinkering with electronics, rock climbing, and natural farming. In the past, he received a bachelor’s degree in photography and worked as a freelance photographer.

Table of Contents

Preface

1

Exploring the Godot 4 Editor

Technical requirements

Navigating in the new Godot 4 Editor

How to do it…

How it works…

Exploring the new features in the Project Settings dialog

How to do it…

How it works…

What’s new in the Editor Settings dialog

How to do it…

How it works…

2

Transitioning to GDScript 2.0

Technical requirements

Investigating annotations in Godot 4

Getting ready

How to do it…

How it works…

Using properties with getters and setters

Getting ready

How to do it…

How it works…

Using the new await keyword and coroutines

Getting ready

How to do it…

How it works…

Using the super keyword to call a function

Getting ready

How to do it…

How it works…

Working with typed arrays

Getting ready

How to do it…

How it works…

Working with lambda functions

Getting ready

How to do it…

How it works…

Using callables with signals

Getting ready

How to do it…

How it works…

3

2D and 3D Rendering with Vulkan

Technical requirements

Showing off SDFGI

Getting ready

How to do it…

How it works…

Using Volumetric Fog to enhance your games

Getting ready

How to do it…

How it works…

Understanding the FogVolume node

Getting ready

How to do it…

How it works…

Working with particle nodes in Godot 4

Getting ready

How to do it…

How it works…

Using decals in your game

Getting ready

How to do it…

How it works…

4

Practicing Physics and Handling Navigation in Godot 4

Technical requirements

Using Heightmap for 3D terrain

Getting ready

How to do it…

How it works…

Setting up and moving the CharacterBody in 2D

Getting ready

How to do it…

How it works…

Setting up and moving the CharacterBody in 3D

Getting ready

How to do it…

How it works…

Using the new NavigationServer for 3D

Getting ready

How to do it…

How it works…

Using NavigationServer2D for 2D projects

Getting ready

How to do it…

How it works…

Using SoftBody for 3D games

Getting ready

How to do it…

How it works…

5

Playing with Shaders in Godot 4

Technical requirements

Creating shaders with the Shader Creation dialog

Getting ready

How to do it…

How it works…

Exploring Uniform Arrays in the Godot 4 shader language

Getting ready

How to do it…

How it works…

How to use Global Uniforms

Getting ready

How to do it…

How it works…

Using Instance Uniforms with shaders

Getting ready

How to do it…

How it works…

Exploring the Visual Shaders Context menu

Getting ready

How to do it…

How it works…

Working with Integer and Comment nodes

Getting ready

How to do it…

How it works…

Creating nodes using Texture3D and CurveTexture

Getting ready

How to do it…

How it works…

Using the Billboard node

Getting ready

How to do it…

How it works…

Using the UVFunc node

Getting ready

How to do it…

How it works…

Improving the Sky Shader mode

Getting ready

How to do it…

How it works…

What the Fog Shader mode can do

Getting ready

How to do it…

How it works…

6

Importing 3D Assets in Godot 4

Technical requirements

Importing Blender blend files into Godot 4

Getting ready

How to do it…

How it works…

Importing FBX files into Godot 4

Getting ready

How to do it…

How it works…

Importing glTF files into Godot 4

Getting ready

How to do it…

How it works…

Using the Import dialog

Getting ready

How to do it…

How it works…

7

Adding Sound and Music to Your Game

Technical requirements

Working with AudioStreamPlayer

Getting ready

How to do it…

How it works…

Exploring directional sound in 2D

Getting ready

How to do it…

How it works…

Using directional sound in 3D

Getting ready

How to do it…

How it works…

8

Making 2D Games Easier with TileSet and TileMap

Technical requirements

Using the new TileSet editor

Getting ready

How to do it…

How it works…

Examining TileMap layers

Getting ready

How to do it…

How it works…

Playing with the new TileMap tools

Getting ready

How to do it…

How it works…

Playing with Tile Atlas editing

Getting ready

How to do it…

How it works…

Exploring the TileSet physics

Getting ready

How to do it…

How it works…

Exploring the TileSet navigation

Getting ready

How to do it…

How it works…

Creating Custom Data Layers with the TileSet

Getting ready

How to do it…

How it works…

Painting terrains in TileMap

Getting ready

How to do it…

How it works…

Transitioning TileSet terrains

Getting ready

How to do it…

How it works…

Organizing isometric tiles into fixed-sized grids using the TileSet resource

Getting ready

How to do it…

How it works…

9

Achieving Better Animations Using the New Animation Editor

Technical requirements

Exploring changes with transform tracks

Getting ready

How to do it…

How it works…

Investigating the new Bezier curve workflow

Getting ready

How to do it…

How it works…

Playing with 3D rotation animations

Getting ready

How to do it…

How it works…

Working with bone poses

Getting ready

How to do it…

How it works…

Triggering a transition

Getting ready

How to do it…

How it works…

Playing with the new Movie Maker mode

Getting ready

How to do it…

How it works…

10

Exploring New Multiplayer Features in Godot 4

Technical requirements

Using the new MultiplayerSpawner node

Getting ready

How to do it…

How it works…

Using the new MultiplayerSynchronizer node

Getting ready

How to do it…

How it works…

How to use the Headless mode

Getting ready

How to do it…

How it works…

How to use UPnP with P2P networking

Getting ready

How to do it…

How it works…

Index

Other Books You May Enjoy

1

Exploring the Godot 4 Editor

Godot is a free open source game engine that was created by Juan Linietsky and Ariel Manzur in 2007. It was released under the MIT License in 2014. You can download Godot from https://godotengine.org/. The following is from the Press Kit on the website:

The name Godot Engine should always be written in Title Case. Also, Godot should be written with only one capital letter – it’s not “GoDot”. Godot is named after the play Waiting for Godot, and is usually pronounced like in the play... For native English speakers, we recommend “GOD-oh”; the “t” is silent like in the French original.

Godot uses a tree of nodes inside a scene. A scene can be instanced in many different scenes. Godot’s integrated language, GDScript, is a Python-like language that is very easy to learn.

Godot is written in C++, which you can use to edit the Godot Engine or contribute to the engine itself. Godot also officially supports C#; to use C# with Godot 4, you need to download Godot Engine - .NET. There are community-supported languages, such as Rust, Nim, Haskell, Clojure, Swift, and D, that you can use: https://godotengine.org/.

Godot 4 is the newest version of the Godot Engine. It uses the Vulkan renderer, which is more powerful for 3D and 2D games than OpenGL, which was used in Godot 3.x. In this book, we will learn what was changed or added to Godot 4 and how to use these features to create games whether to sell or just for fun.

In this chapter, we’ll look at the changes between Godot 4 and Godot 3.x in the Inspector tab under Node | Process | Mode. We will also look at the new preview Sun and Environment dialog. In the Project Settings dialog in Godot 4, we’ll look at the Advanced Settings button, and in the Input Map tab, we’ll look at the Show Built-in Actions button as well as the Shader Globals tab. In the Editor Settings dialog, we’ll look at the differences between the Interface | Editor tab and the Interface | Text Editor tab.

This chapter is a little different in that we are looking at the differences between Godot 3.x and Godot 4, so there is not much to do except to show the differences. The reason we’ve included this chapter is that some things have changed, and you might find it difficult to find what you are looking for; for example, now you need to click a button to show you the Input Map options.

In this chapter, we will cover the following recipes:

Navigating in the new Godot 4 EditorExploring new features in the Project Settings dialogWhat’s new in the Editor Settings dialog

Technical requirements

For this chapter, you need the standard version of Godot 4.0 or later running on one of the following:

Windows 64-bit or 32-bitmacOSLinux 64-bit or 32-bitAndroidWeb Editor

Navigating in the new Godot 4 Editor

For this recipe, open up Godot 4 and follow along. To have a look at the process_mode property, select the new preview Sun and Environment dialogs and then select Inspector | Node | process_mode. We’ll then look at the three renderer options in Godot 4.

How to do it…

Let’s execute the following steps:

Open a new project in Godot 4.In the Scene tab, click on 3D Scene.Click the three vertical dots on the viewport toolbar to the left of Transform. You can see them highlighted in a blue box in Figure 1.1.Click the Add Environment to Scene tab on the bottom right of the dropdown.

You can preview the Sun or Environment nodes when you import models, or you can add them to the scene.

Figure 1.1 – Edit Godot 4 Sun and Environment settings

Click on World Environment under Node3d in the Scene tab.In Inspector, click on the Environment type and then click on Sky. The two resources are now highlighted in different colors.

Figure 1.2 – Godot 4 Inspector highlights

The following screenshot shows what it looked like in Godot 3.x.

Figure 1.3 – Godot 3.x Inspector highlights

Click on the Node3d node in the Scene tab and hit the Delete key, or right-click and select Delete.In the Scene tab, click 2D Scene.In Inspector, under Node, you will see Process. Open it by clicking on it and notice Mode with Inherit to the right with a drop-down arrow.

Figure 1.4 – Godot 4 Inspector with Process opened, showing the default values

Click on the down arrow on the far right or on Inherit to open the options.

Figure 1.5 – Godot 4 Inspector with Process and Mode opened

Note

Pause Mode | Process in Godot 3.x is now Process | Mode, and you can now disable a node. If you do, the node will be grayed out on the SceneTree.

The Godot 3.x Pause Mode option can be seen in the following figure.

Figure 1.6 – Godot 3.x Pause Mode

In the top right-hand corner of the Godot Editor is a green Forward+ button. If we click on this, we will see Forward+, Mobile, and Compatibility.

Figure 1.7 – Change the renderer

How it works…

We opened the new Sun and Environment dialogs, which can be used to preview imported assets or when editing 3D scenes to see how they look when lighting is added. You can also add the Sun and/or the environment to the game easily from the Sun and Environment dialogs.

We looked at how resources and sub-resources are highlighted in Inspector and how they stand out because of the different colors, which makes it easier to see a sub-resource over a resource. In Godot 3.x, it was all one color, so sometimes, you didn’t know where a sub-resource stopped and another began.

Then, we saw how the process and pause settings are now in a single menu and you can disable a node as well. Once disabled, the node is grayed out on the SceneTree. The node and any children of the node will not be processed at all.

We clicked on Forward+ in the top right-hand corner of the Editor and a drop-down list with Forward+, Mobile, and Compatibility appeared. These are the renderers that we can use in a project. Forward+ is a high-end renderer that scales well with complex scenes for desktop devices. Mobile is for mobile devices that do not scale as well to large scenes with many elements like Forward+ does. Compatibility is for older devices that need to use a low-end renderer.

Exploring the new features in the Project Settings dialog

In this recipe, we will look at the Advanced Settings button in Project Settings, which opens all of the options available for all of the project settings listed. The Input Map Show Built-in Actions button opens all of the available user input actions that can be set for your game. The Shader Globals tab in Project Settings is for global uniforms.

How to do it…

To find the Project Settings Advanced Settings button, the Input Map Show Built-in Actions button, and the Shader Globals tab, execute the following steps:

Open a new or any existing project in Godot 4.In the top-left menu, click Project, and then click Project Settings.

The default settings now only show the basic settings.

Figure 1.8 – Godot 4 Project Settings default settings

On the right of the Search box, click the Advanced Settings button.

Figure 1.9 – Godot 4 Project Settings Advanced Settings button clicked

Now all of the settings options are viewable like in Godot 3.x.

Click the Input Map tab to the right of the General tab. Notice that there is nothing shown.

Figure 1.10 – Godot 4 Input Map default settings

Click the Show Built-in Actions button to the right of the search field. Notice that it now has many more options than Godot 3.x. Scroll down to see all of the options.

Figure 1.11 – Godot 4 Input Map Show Built-in Actions button clicked

Click the Shader Globals tab, which is the third tab to the right of Input Map. This is a new addition in Godot 4 to use with global uniforms.

Figure 1.12 – Shader Globals tab in Project Settings

How it works…

We opened the Project Settings dialog and noticed that there was not much showing like in Godot 3.x. We saw that a new Advanced Settings button was added that showed everything.

Next, we opened the Input Map tab and found there was nothing showing by default. We learned that a new Show Built-in Actions button was added and when pressed, all of the user input options of Godot 3.x and more are shown.

We opened the new Shader Globals tab, which is used for global uniforms and allows you to change many shader behaviors at the same time.

What’s new in the Editor Settings dialog

In this recipe, we will look at the differences in the Editors and Text Editors in Editor Settings between Godot 3.x and Godot 4.

How to do it…

To find the Editors and Text Editors in Editor Settings, execute the following steps:

Open a new or any existing project in Godot 4.In the top-left menu, click Editor, and then click Editor Settings.On the left, where you see Interface, scroll down to Text Editor.Click Theme under Text Editor.

Figure 1.13 – Godot 4 Text Editor – Theme

The following screenshot shows what it looked like in Godot 3.x.

Figure 1.14 – Godot 3.x Text Editor – Highlighting

Notice that the Highlighting settings in Godot 3.x are now under Theme in Godot 4.

Scroll down to the next section, called Editors, and click on Panning, which is new to Godot 4.

Figure 1.15 – Godot 4 Editor – Panning

The following screenshot shows what it looked like in Godot 3.x.

Figure 1.16 – Godot 3.x Editor – no panning

Notice the new Panning and Bone Mapper settings.

How it works…

In this recipe, we looked at Theme in the Text Editor settings in steps 2-4 and noticed that there are fewer settings compared to Godot 3.x. The Highlighting settings can now be found under Theme.

We looked at the new Panning settings, where we can change the 2D Editor's, Sub Editors', and Animation Editors' Panning Schemes to make the mouse scroll wheel pan or zoom in those editors. We saw that Bone Model was also added to the Godot 4 Editor settings. Go through all of the Project Settings and Editor Settings tabs to see what has changed.