2 Scenes 1 Object


I have added the HUD scene as overlay:

        #get the actuators (from camera)
        self.HUD = cont.actuators["hud"]

At same time i use the HUD scene as the prime storage for ObjectsPrototypes.
Planing on create objects in realtime in the main scene based on their Prototypes.

The API states that Overlay scenes can be accessed…API
This command however just returns me a list with only the main scene.

I have also a crosshair in the Overlay scene that shows like it should.

I can see the Overlay scene called HUD
but i can not get its reference.

How should i go about thi, to get the reference to it?

Normally scenes are accessible through. sce= bge.logic.getSceneList(); the main scene in you case will be sce[0] and the overlay sce[1]
objects in the overlay scene can be found at sce[1].objects.
You don’t need to access the actuator that adds the scene!

I just finished with some tests.
The only misstake i have been doing is to try to get it on the first tick.
After the first tick its no problem to get it.

I just use this way to to send an activtion impulse to the actuator.
anyway Thanks :slight_smile:

Edit: i have been too fast.

from bge import logic

allScenes = logic.getSceneList()

own = logic.getCurrentController().owner

mainS = allScenes[0]
hudS = allScenes[1]

OoS = hudS.objects["Orb of Stone"]


This does not work, why?
It creates the Object in the hudS, while i clearly ordered it to create it in the mainS…

A) There is no “Main” scene in the BGE. The BGE treats all scenes the same. “Main”, "HUD"m “Overlay” is a semantic nomenclature for the reader.

B) You can’t use game objects of one scene to be added (AddObject) in another. The data must be at the target scene already:

  • by being present at scene start (active or inactive)
  • by being loaded via LibLoad

===> The data are encapsulated in the scene they reside in!

If the object orb of stone exists on the main scene, you don’t need to add it to a variable, just summon it directly:
main.addObject(‘orb of stone’, own).
Besides, the object is presumed being in a hidden layer, so you are asking for an object that is on active layer in another scene.