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.