Hi everyone! I make a 3d game (action RPG) and I want to have in game main menu like Dark Souls and many other games. So I made a 2D scene with buttons (Main menu). When I press the button "New Game" Level 1 of game should load. But it crashes and no errors displayed. I try add_child(), change_scene_to_file() and change_scene_to_packed() result the same. When I run Level 1 scene manualy it work just fine, I do not understand what I do wrong.Below I attach some screenshots of my project related to this question, if anyone could help me? Also I set menu scene as root in project settings


  • Jesusemora replied to this.
  • NazarK0 Nothing crashes. The level loads normally just that it's fully obscured by your loading scene which is not getting removed. And that's because load_done signal handler LoadingScreen::_startOutroAnimation() gets stuck on first await.
    In general it's not a very good idea to await form _process() for multitude of reasons. So try to avoid doing that.

    Btw one of the first thing you want to do for pleasant debugging is to implement runtime mouse capture toggle as well as set the game window to be on top (in editor settings), so you can navigate the editor debugging features while observing what happens in the game window.

    When hunting for bugs, prints need to be placed (and removed) strategically, in order to gradually zero-in on the bug.

    The project is still missing a resource: res://resources/meshes/assets/dungeon_texture.png

    NazarK0 you are adding a child to the scenetree.
    1 - get rid of PreloadScreen.
    2 - try creating a root scene with a Node or Node3D as root. put your UI in a scene as children of a single Control.
    3 - load the scene with a single node and have it then load the 2D scene.
    4 - when changing scenes, instantiate the 3D scene first, then delete the Control that is parent to the UI.

    as long as a 2D node/Control is parented to a camera, it will show in a 3D environment. Try to work in 3D and use viewport containers to hold 3D scenes in 2D, or put your 2D scenes as parented to the camera.
    don't swap between 2D and 3D.

    many modern games have a 3D main menu, even if no 3D is shown.

    NazarK0
    1 - you have 48 warnings
    2 - what does it mean "it crash"? you have to be more specific. what level of crash are we talking about? does it return to the editor with an error (and if so what error)? does it core dump? does it stop working forcing you to ctrl+alt+del?
    3 - please show a screenshot of the editor after running the game so we can see the hardware description in godot, or tell us what hardware you are running it on. you are on forward+ and that requires a modern computer with support for vulkan 1.1/1.3.
    4 - it could also be the code.

    you are connecting the signal in editor to a script in new game.
    try putting the script in Control instead and connecting from there, and then doing queue_free() instead of %Control.queue_free()

    doing % is equivalent to get_node().

    the FileSystem is also missing level_1 somehow.

    also, instantiate the level when the button is pressed, otherwise the level is kept in the background.

    main_menu.gd

    @export var level1 : PackedScene #set your level1 in inspector, the path will update if you move the file
    
    func _on_pressed() -> void:
         var new_game = level1.instantiate() #load the level
         add_sibling(new_game) #add the new node parallel instead of as child
         queue_free() #delete self, IE Control, containing the entire menu

      Jesusemora

      I handle all warnings, they are mostly by static typing. Right now only one warning remaining. I create new 3d menu, also load manager, nothing changed

      Load manager script:

      `extends Node

      signal progress_changed(progress: float)
      signal load_done

      var _load_screen_path: String = "res://scenes/gui/loading_screen.tscn"
      var load_screen: PackedScene = load(load_screen_path)
      var _loaded_resource: PackedScene
      var _scene_path: String
      var _progress: Array = []
      var _use_sub_threads: bool = true

      func process(delta: float) -> void:
      var load_status: ResourceLoader.ThreadLoadStatus = ResourceLoader.load_threaded_get_status(_scene_path, _progress)

      match load_status:
      	ResourceLoader.ThreadLoadStatus.THREAD_LOAD_INVALID_RESOURCE, \
      	ResourceLoader.ThreadLoadStatus.THREAD_LOAD_FAILED:
      		set_process(false)
      		return
      	ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS:
      		emit_signal("progress_changed", _progress[0])
      	ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED:
      		_loaded_resource = ResourceLoader.load_threaded_get(_scene_path)
      		emit_signal("progress_changed", _progress[0])
      		emit_signal("load_done")
      		get_tree().change_scene_to_packed(_loaded_resource)

      func loadScene(scene_path: String) -> void:
      _scene_path = scene_path
      var new_loading_screen: LoadingScreen = _load_screen.instantiate()

      get_tree().get_root().add_child(new_loading_screen)
      
      self.progress_changed.connect(new_loading_screen._updateProgressBar)
      self.load_done.connect(new_loading_screen._startOutroAnimation)
      
      await Signal(new_loading_screen, "loading_screen_has_full_coverage")
      
      startLoad()

      func startLoad() -> void:
      var state: Error = ResourceLoader.load_threaded_request(_scene_path, "", _use_sub_threads)

      if state == OK:
      	set_process(true)

      `

      When I say

      it crashes

      I mean that when I press "new game" button" game just close, no errors, nothing. But when I separately run Level_1 scene it run, and play

      Sometimes it work as espected, but it is 1 to 100 approximately

      progress bar go to 100% and game close

      I change level_1 to new_game.tscn, nothing

      • xyz replied to this.

        NazarK0 Debugging 101: Put a print statement every step of the way.

          NazarK0 The project has missing resources.
          Better to create a minimal reproduction project that demonstrates the problem.

            xyz The project has missing resources.

            It's:
            KayKit - Dungeon Pack
            KayKit - Character Pack : Adventurers
            KayKit - Character Pack : Skeletons

            NazarK0 I just create github repository for this game:https://github.com/NazarK0/3d-RPG-game

            But a bunch of errors and the game won't launch:

              I update dependencies and push to repo

              Tomcat I fix this, sorry) Working from godot IDE with github not as easy as want to be))

              xyz It is a lot of prints will be (・о・). I try to make breakpoints, but it not help me

              • xyz replied to this.
                NazarK0 changed the title to Changing scene from main menu to 3d game crashes .

                NazarK0 Nothing crashes. The level loads normally just that it's fully obscured by your loading scene which is not getting removed. And that's because load_done signal handler LoadingScreen::_startOutroAnimation() gets stuck on first await.
                In general it's not a very good idea to await form _process() for multitude of reasons. So try to avoid doing that.

                Btw one of the first thing you want to do for pleasant debugging is to implement runtime mouse capture toggle as well as set the game window to be on top (in editor settings), so you can navigate the editor debugging features while observing what happens in the game window.

                When hunting for bugs, prints need to be placed (and removed) strategically, in order to gradually zero-in on the bug.

                The project is still missing a resource: res://resources/meshes/assets/dungeon_texture.png

                  dungeon_texture.png I added, but now this error:

                    Tomcat The script is trying to preload a missing resource res://scenes/levels/level_1.tscn. But this doesn't really matter for the actual issue as that script appears not to be used.

                    xyz maybe my notebook lack of resources, I try to run on pc

                    • xyz replied to this.