I’m still a python newbie is there any way to get this to work?
I read the KX_Scene document i really didn’t find anything useful.
remove “WORLD”
add behind ()
[“WORLD”]
i got 2 simple functions for this job if you want it
def get_scene(scene_name):
scenes = logic.getSceneList()
scene = None
for sce in scenes:
if sce.name == scene_name:
scene = sce
return scene
def get_object(scene_name, object_name):
scene = get_scene(scene_name)
object = scene.objects[object_name]
return object
obj = get_object("WORLD", "Player_Cam")
```
1 Like
thank you! i will test and see what works!
so I did a bit more reading and rewrote the whole script and I found out that scenes are numbered but now I’m getting another error lmao
Scene = bge.logic.getSceneList()["SceneName“]
1 Like
Please note that @BluePrintRandom’s code will only work in UPBGE 0.0.1+ versions, not vanilla BGE. Proof here. For normal BGE, you’ll need to go the old fashion route:
for s in bge.logic.getSceneList():
if s.name == "different_scene":
#doSomething()
1 Like
try this:
from bge import logic
def get_scene(scene_name):
scenes = logic.getSceneList()
scene = None
for sce in scenes:
if sce.name == scene_name:
scene = sce
return scene
def get_object(scene_name, object_name):
scene = get_scene(scene_name)
object = scene.objects[object_name]
return object
own = logic.getCurrentController().owner
always = own.sensors['always']
obj = get_object("WORLD", "Player_(Box)")
if always.positive:
own.worldOrientation = obj.worldOrientation.copy()
Make sure the scene you want to acces is active, if the scene does not exist ingame then you can’t get data from it.
1 Like
It works !!!