When i’m running more than one instance of the game, is there any quick way to tell which instance of the game is the one that gets its scene tree displayed under “Remote” in the editors scene tab?.

  • anteaters@feddit.de
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    1 year ago

    It’s the “first” instance that opens - on my machine it corresponds to the window order in the taskbar. The feature to configure the started instances with parameters is not yet merged into Godot 4 but I think for 3 there’s an addon in the asset library to give your started instances some parameters to help you identify them.

    If you just want to quickly see which window you have in the “remote” tree view, I’d suggest a quick and dirty autoload script like this:

    extends Node
    func _ready():
        name = str(randi_range(111,999))
    
        # Chill for a frame in case some other script sets the window title
        await get_tree().process_frame
        DisplayServer.window_set_title("Window: %s" % name)
    

    Put it at the end of the autoload queue and it will create a top level node with a random-number as the name and also put that name in the window title. Note that this is for Godot 4.

    Alternatively if you don’t want to write the number into the window’s title you can also get the name property of the autoload and write in in a label somewhere in your UI.

    • Ti_Ka@lemmy.blahaj.zoneOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      1 year ago

      Wow thanks for the quick and detailed answer :D. Ive used a variation of the autoload script you provided and it works great.

      on my machine it corresponds to the window order in the taskbar.

      I tried that at first too but its not very reliable on my machine and it seem they can be in any order on my taskbar.

      (I actually went back and checked now that i can easily tell which one it is and it appears like it is often, but not always, the one last in my taskbar (out of 3 open instances). ~30%-50% of the time it can also be the second to last one and i recall it even being the first one in the taskbar at least once)