Home Game Development Godot 4 Game Development Cookbook

Godot 4 Game Development Cookbook

By Jeff Johnson
ai-assist-svg-icon Book + AI Assistant
eBook + AI Assistant $35.99 $24.99
Print $44.99
Subscription $15.99 $10 p/m for three months
ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription.
ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription. $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime! ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription.
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Along with your eBook purchase, enjoy AI Assistant (beta) access in our online reader for a personalized, interactive reading experience.
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription. ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription. BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime! ai-assist-svg-icon NEW: AI Assistant (beta) Available with eBook, Print, and Subscription.
eBook + AI Assistant $35.99 $24.99
Print $44.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
Gain access to our AI Assistant (beta) for an exclusive selection of 500 books, available during your subscription period. Enjoy a personalized, interactive, and narrative experience to engage with the book content on a deeper level.
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Along with your eBook purchase, enjoy AI Assistant (beta) access in our online reader for a personalized, interactive reading experience.
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Chapter 2: Transitioning to GDScript 2.0
About this book
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.
Publication date:
June 2023
Publisher
Packt
Pages
258
ISBN
9781838826079

 

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

 

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-bit
  • macOS
  • Linux 64-bit or 32-bit
  • Android
  • Web 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:

  1. Open a new project in Godot 4.
  2. In the Scene tab, click on 3D Scene.
  3. 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.
  4. 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

  1. Click on World Environment under Node3d in the Scene tab.
  2. In Inspector, click on the Environment type and then click on Sky...
 

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:

  1. Open a new or any existing project in Godot 4.
  2. 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

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

Figure 1.9 – Godot 4...

 

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:

  1. Open a new or any existing project in Godot 4.
  2. In the top-left menu, click Editor, and then click Editor Settings.
  3. On the left, where you see Interface, scroll down to Text Editor.
  4. 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.

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

Figure 1.15 –...

About the Author
  • Jeff Johnson

    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. Towards the end of developing “Escape From 51” he changed engines to Godot 3.0.2 and 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.

    Browse publications by this author
Godot 4 Game Development Cookbook
Unlock this book and the full library FREE for 7 days
Start now