Question: 'scene'.objects['x'] works for all layers?

Hi, ok so I thought that if I had a scene with one main layer and other layers which would hold objects to add, using getCurrentScene() to access these objects would work, and it has before I think, but it seems that they don’t the way that I have it set up. So here’s the code that I’m using:

#Note this isn't the whole thing just small pieces, it's in a large script
scene = bge.logic.getCurrentScene()
selectedItem = scene.objects[inv['selectedItem']]  #Where inv['selectedItem'] is the name of an object in layer 3

It gives me this error: KeyError: “CList[key]: ‘’(name of object)’’ key is not in list”
However, when I move the objects to layer 1, I don’t get any errors. Any ideas?


If the layer is inactive then all objects in that layer are inactive. So search in scene.objectsInactive instead.

ok thanks i’ll try that :slight_smile:

Yes thanks you it works!!