Upbge 0.3 access bpy game objects

I don’t think it’s possible to get the bpy scene objects from KX_gameobjects ?
For example spawn cubes into the scene and keep them persistent, you close game and the object stays in the 3D scene.

you could write a saveload in bge, run game, save it, on exit have a bpy script ready to convert these data into the 3dview.

Right, this is a way staingwith Bge engine.
Perhaps i also will try to simplye make some addon like script i run from the editor, those type of script modify a scene without needing to save load.
I didn’t find a good example addon script showing how to example duplicate some object to mouse position on click for example.

Access Blender objects from BGE KX_gameobjects would could have been a work around.

well, i’m bad with bpy so you should use google. but basically you only need a save script, so when you end the game, it saves the data you need to an .txt or somthing, then use bpy to add and move them into the 3d view.

Moving objects with bpy is not that hard, you can look at my addon if you like. or google it, first example you get is moving an object. How to add objects with bpy is something to search for. Or you could ask very nicely @BluePrintRandom if he knows it.

yeah in upbge 0.3.0 you just uncheck ‘undo on exit’

but I am unsure about added objects *

try it out

also upbge 0.3.0 the KX_Object.blenderObject.data is the mesh

you can export / import / convert to KX_gameObject in game now !

There’s an API to get the bpy.types.Object from bge.types.KX_GameObject in 0.3 alpha experimental:

bl_ob = kxob.blenderObject

to access data (it can be a mesh, light data…):

mesh = kxob.blenderObject.data
1 Like