8

Splitting and Reusing Scenes

It is possible to create the whole game within one Godot scene, but this can get quite unwieldy. Not only do we have to recreate every part over and over again, such as every boulder or enemy, but if we want to change something about the rocks, we have to go and find every rock to change them.

This is not scalable for any kind of game. Luckily, in Godot, there are such things as scenes. In Chapter 2, we saw how to create new scenes from scratch, but in this chapter, we will learn how we can create a scene for each element so that we can easily reuse it throughout the game. This way, we can make one scene for the rocks and use that to populate the arena instead of having multiple unique rocks.

Next to reusing components, ...

Get Learning GDScript by Developing a Game with Godot 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.