upbge
upbge copied to clipboard
Version 0.2.5 Scenes loaded from "libload" load a duplicate scene into the Main scene
If you run everything from a single blender file, when you "add a scene", it successfully adds the scene.
However if you libload that same file from another blender file and THEN "add a scene" as you have done before, an error occurs where it loads duplicate objects from the newly added Scene in the "Main Scene".
In this example, you can see when I libload an example file and "add a scene" it duplicates the added object twice. This is unexpected behavior and does not function the same way in Blender Game Engine, also it doesn't function this way in UPBGE in a single file, the error only occurs with libloaded scene/library.
Here in this example gif The stationary square is the scene being added correctly,
and the red cube in motion is the duplicate object which has loaded into the main scene.
Here is the Zip File demonstrating the issue: *Just open "Example.blend" and run the game by pressing "P"
https://www.dropbox.com/s/nbi4gznlm73j84c/Libload_Bug.zip?dl=0
I was doing several tests and I don't see clearly the issue. I mean:
- The blend is libloaded 2 times. The second one is rejected because is was loaded before. This behaviour seems me OK.
- When you libload a blend all the objects in all the scenes are loaded. Then the static cube loaded seems me OK.
- Then you add a scene using a camera then the "dynamic" cube follows the movement of this scene. This one i don't know if it correct (it seems me similar to the overlay behaviour but i don't know).
Could you explain it again or maybe what do you expect from libload and what do you expect from addScene?
Thanks for your time
Here is the video with me showing the issue, hopefully this is helpful! https://www.dropbox.com/s/rmatlxqfr8soh92/2020-07-13%2013-45-16.mp4?dl=0
This is the simplest way I can summarize the issue: libloading a "scene" from another blender file, loads the "scene" and all other scenes as well.
This does not happen in BGE, only seems to effect UPBGE.
Hi,
- The blend is libloaded 2 times simply because the sensor triggers the python brick twice. you need to test wether it is positive or not
- same thing in example.py : you need to test if the sensor is positive
def load_game_intro():
cont = bge.logic.getCurrentController()
sens = cont.owner.sensors['Begin Game']
print(sens.name,'sensor is',sens.positive)
if sens.positive:
path = bge.logic.expandPath("//" + "lib/" + "load_example" + ".blend")
bge.logic.LibLoad(path, 'Scene', load_actions = True) #, load_scripts = True, scene="load")
- as lordloki said, When you libload a blend all the objects in all the scenes are loaded... and visible IF they are in an active layer
- so you need to add scene with nothing in active layers, then addScene(), then add objects in it
- libloaded objects can also be added in the scene you call libload() from
actually bge behaves the same way, except for the sensors that work better than before to my pov.
here is an update of your testfiles, tested a lot of things before to figure out, so you 'lower-scene' is now 'b' : Libload_Bug.zip