2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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? $\endgroup$
    – kheetor
    Commented Apr 28, 2016 at 5:29

1 Answer 1

1
$\begingroup$

You can't duplicate objects that are not present within the scene you want to have them in.

If they are not present already you might load them into the scene via LibLoad. I suggest to do that only when you need dynamic loading.

The easier way is to link the object (or mesh) from the original scene to the other scene. This means when you edit the object in either scene both objects get updated. Be aware: they are only linked in Blender not in the BGE. in the BGE they are two different objects.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .