Hey everyone,
quite straight-forward question: How do I add an object into a scene, which comes from another scene?
Two scenes are active, ‘Scene’ and ‘importscene’. ‘importscene’ does NOT have a camera to prevent his objects becoming visible and draining framerate:
from bge import logic
contr = logic.getCurrentController()
own = logic.owner
scene = logic.getCurrentScene()
impscene = logic.getSceneList()[0] #first scene is importscene
obj = impscene.objects['Cube']
scene.addObject(obj, own,0) #add object 'obj' into scene (='Scene')
The previous script makes my blender crash when ending the game-engine. The funny thing that happens though:
The object IS added into ‘Scene’ its object-list (scene.objects), but is NOT visible in ‘Scene’.
Instead it is added (visible) in ‘importscene’, which can be recognised by the camera-angle and (lack of) lighting (importscene has no lights).
It seems that the ‘.addobject’ does import the object to object-list of the scene that calls it, however it add’s the object visibly in the scene where the object is. This probably causes it to crash when ending it.
Is this a bug? Or am I doing something forbidden?
Ps. I do know about LibLoad(), however, this imports all the objects not only into the memory, but also visible into the scene. That’s why I try to use an importing scene without camera to act as a portal for imported objects via LibLoad(). This way it does not affect the framerate (besides loading of course).