# Adding objects in a different scene than controller's

I have a number of scenes in my game; main, overlay, and underlay. I am currently attempting to use scene.addObject() to add an object in the underlay scene.

Both the argument objects, the object to be added, and the object to be used as position reference, are located in the main scene, along with the controller object which is running my python module.

What I have tried:

I have attempted calling [underlay].addObject() which does not work. It tells me that the blender objects are not in an inactive layer.

    empty = self.scene.addObject('Empty', 'Origin')
ValueError: scene.addObject(object, other, time): KX_Scene (first argument): object must be in an inactive layer


the output of calling scene.objectsInactive on the main scene immediatly before calling addObject is

[Empty, Origin, Placeholder, Lamp, Camera, PHolderCam, Lamp, Camera, StarSphere1]


likewise for the underlay scene it is

[]


I have also tried locating one and both of the objects to be added in an inactive layer of the underlay scene, however this gives me a different error;

ValueError: scene.addObject(object, other, time): KX_Scene (first argument), requested name "pri_underlayEmpty" did not match any KX_GameObject in this scene


I am looking for either a solution to this problem or alternate means to be able to add objects into that other scene, from the controller in main. Help is appreciated, thanks in advance to any answerers.

• Its been a while since I used BGE but I think the objects need to be inactive in the scene where you want to add them. So the empty needs to be inactive in the underlay scene? Apr 28 '16 at 5:29