Can not access game object added in overlay scene I have a text object in a scene. That scene is added at the start of the game as an overlay scene. Whenever I try to access the text object, named "HUD.text" (to change the game text) the bge returns:


  Traceback (most recent call last):
    File "path\to\my\script.py", line 71,
  in main
      HUDtext = hud.objects['HUD.text']
  KeyError: "CList[key]: ''HUD.text'' key not in list"


Which if I'm understanding it right means the object 'HUD.text' is not available for the game engine.

I have checked that the overlay scene is being added correctly (it is), and if I print all the objects in that scene 'HUD.text' is in the array.

I add the overlay scene with this line in a script that runs once at game start. bge.logic.addScene('hud', 1)

hud is defined by hud = bge.logic.getSceneList()[-1] 

print(hud.name) outputs hud  

print(hud.objects) outputs [Plane, HUD.text, Camera.001] 

Is there something I have to do to make objects added in a overlay scene available? Or is there some huge delay in the time it takes to add the scene?

Here is an example blend file showing the error.
You can not use a variable for KX_GameObject that contains characters like ".", ",", "!" etc. You must use only lowercase and uppercase letters and numbers. In this case you must do something like:

HUDtext = hud.ojects["HUD.text"]


or

HUD_text = hud.objects["HUD.text"]


You can use any variable name that contains only letters and numbers. Note that it can't start with number.