scene.addObject Not Working in Overlay Scene

I can’t use scene.addObject() in my overlay scene. I get an error that the object doesn’t exist even though when I print out scene.objectsInactive, it shows the object with the correct naming. (Yes, the object I’m trying to add to the overlay scene IS in the overlay scene on an inactive layer.)

Can you not add objects to an overlay scene? Or is this a bug with my Blender version?

Windows 7 64-bit. Blender 2.69.

Thanks.

I suspect the controller you’re running your code from is not in the overlay scene.

If I recall correctly, the addObject method will only look through inactive object in the scene the current controller resides in when searching for an object that matches the name provided. However, there is a work around. You can manually fetch the reference to the inactive object you want to add and pass that to the addObject method instead like so:

objToAdd = overlayScene.objectsInactive['objName']
overlayScene.addObject(objToAdd, spawnObj)

Thanks a lot Mobious! The controller was in fact in my main scene and not in the overlay scene. For whatever reason I couldn’t get the objectsInactive method to work, but once I knew that the controller had to be in the same scene, I just put the logic on an overlay object and set that object’s state to execute it. Works great. Thanks again!