Problem with bpy code

Hello everyone!
I need some help… Again!
I created a little game with BGE. I got it to work (more or less…), but Monster, here on the BA forum, made me realize I had used the bpy library in my project. And of course this is a BIG problem, because the standalone does not work AT ALL.
For this reason, I am trying to eliminate all the bpy-based commands from my code. The problem is, I’m stuck when it comes to these commands:

myObject =[obj_name[i]]
#deselect all objects in the scene
#activate the object = myObject

I need bge-based commands that do the same things these commands do. So, what I need to be able to do is

  1. select
  2. deselect
  3. activate
    objects within the scene without using bpy code… How do I do this??

Thank you very much!


In the game engine there is no such thing as an object being ‘selected’

You can get an object using:

obj = bge.logic.getCurrentScene().objects['objName']

I’m also unsure what ‘activating’ an object does, or what it’s mirror in bge is.

BGE does not have a concept of a selected and active object. You would have to implement this yourself with some custom python scripts. It sounds like you are going to be in for some trouble because controlling the select and active state of an object only has 2 real uses:

  • To highlight the object
  • To setup the bpy context for running a bpy operator.

Very few of the bpy operators will have similar functionality in the BGE.

Have a look at the BGE guides. They should give you a quite good overview of the BGE logic and how to code with it.