0
\$\begingroup\$

I have created a project. And I have saved 20 scenes for 20 game levels. I have designed each scene but when I hit f5 to play each scene, it shows level1 scene. I don't know what the problem is.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Have you written code to change scenes when you want to transition to the next one? Show us that code. \$\endgroup\$
    – DMGregory
    Apr 13, 2023 at 12:51

1 Answer 1

1
\$\begingroup\$

If you just want to test out a given scene independently, you can use:

  • F6 to play the scene that's currently active in the editor.
  • Control+Shift+F5 to play a custom scene (brings up a selection menu).

By default both of the above should have icons in the upper right hand corner: enter image description here

Otherwise, if you want to change the scene via code (for example change to level 2 after level 1 has been completed), there's an example of changing scenes in the documentation:

func _my_level_was_completed():
    get_tree().change_scene("res://levels/level2.tscn")

Note: the docs I linked are for version 3.6 stable - the most current pre 4th edition at the time of writing this answer. If you want the 3.1 version, you can find that here. In general, change_scene is valid for all 3.x versions of Godot; in Godot 4 you use change_scene_to_file instead of change_scene.

Note: If you already have code for changing scenes & it's not working, you'll need to edit your post to include that before anyone can attempt to troubleshoot it.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ That change_scene example is correct for all Godot 3.x (In Godot 4 you use change_scene_to_file instead of change_scene). The reason why it could have been difficult to find it in Godot 3.1 documentation is because they moved things around in the documentation, which was for Godot 3.4 I believe. Anyway, here is the example in the documentation for Godot 3.1: Changing current scene. \$\endgroup\$
    – Theraot
    Apr 13, 2023 at 23:00
  • \$\begingroup\$ @Theraot Awesome info! I've folded that into my answer. I appreciate you taking the time to point that out. \$\endgroup\$
    – Pikalek
    Apr 14, 2023 at 4:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .