Godot Version
v.4.3.stable.official
Question
Hello! I’m very new to Godot, and I’m trying to make a pretty linear game that has Chapter 1, Chapter 2, etc, obviously with each one having a different content but sharing similarities (e.g. that each chapter has a chapter title). I want these chapters to happen one after another (for now, they should just show the chapter title and then start the next chapter).
What’s the best way to go about this?
What I have so far:
I’ve created a Chapter scene (chapter.tscn) (class name Chapter
) with exported variables such as chapter_name
(of type String) and next_chapter
(of type Chapter).
Then I added several of those Chapter scenes to my main game scene (Chapter1, Chapter2, …), giving them names and assigning the next chapters.
I also added an exported variable first_chapter
in my main game node so I can refer to the first chapter in the code.
What I want to do (but don’t know how):
In the script of my main game scene (which is my main menu), I want to switch to the scene of the first_chapter
(which is of type Chapter
) when the “New Game” button is pressed. (Then that scene would do some stuff like show the chapter title and switch to the next chapter.)
Unfortunately, I don’t know how to switch to that first_chapter
scene.
I know how to switch to a scene file (get_tree().change_scene_to_file(“res://chapter.tscn”)
) but that is not what I want to do here; I don’t want to switch to the Chapter scene in general, but specifically the instance Chapter1 in my tree (in my first_chapter
variable)
I hope this makes sense… I couldn’t find anything on this topic at all, so I assume I severely misunderstood how to use scenes and scene instances. I would really appreciate any tips!