GE gameObject / classObject relationship

Hi all,

I’m trying to code with a 1:1 gameObject / classObject relationship; in other words, every game object has a python class object, and each of these python class objects has it’s own game object. I am able to associate a gameObject with each class object just fine. However, I cannot for some reason seem to associate a class object with a game object via something similar to this in a class method: gameObject.myClass = self

To illustrate the problem, please take a look at this blend:

http://tellim.com/random/test.blend

If I for some reason am not allowed to add a class object as a game object attribute, how then can I associate a class object with it’s game object?

Thanks,
spiderworm

Your the only one that knows what your doing, but I can’t quite understand the motive. The objects are all ready instances of classes. You can assign them properties, etc. It seems redundant and will probably slow the engine.

I’m not quite fluent with the ins and outs of python quite yet, but it might have something to do with the fact that you’re trying to assign an instance of the class to a variable while you’re still in the instance’s constructor (at least I’m assuming “init” means it’s a constructor.

Good programming, as i understand it, involves creating a logical hierarchy of objects with objects being linked to related objects by assigning them logical attiributes. Objects should allow methods to be assigned to them as well.

If I cannot assign related objects as properties to gameObjects, then this whole good method of OOP goes out the door. I haven’t tried it out yet, but I wouldn’t be surprised if I can’t assign custom methods to gameObjects either.

My thought was that, since what can be done to gameObjects is somewhat limited, I should create Python classes to wrap around the relevant gameObjects. This is apparently complicated as well since controllers can only attach themselves to gameObjects and not Python objects, therefore it is difficult to associate a gameObject with it’s wrapper python class object.

How frustrating. I said something in #gameblender that I believe sums up my GE-python experience thus far: in the attempt to make an interface that would allow non-programmers to make simple games, they’ve handicapped programmers’ ability to make complex games with it

spiderworm

Thanks, I’ll tweak my file around a bit and see if that fixes it.

spiderworm

spiderworm,

GameBlender’s game object doesn’t allow to store Python objects as its properties, just simple values (number, string…). That’s limitation of GameBlender Python interface. I have done workaround by creating global array of objects and every GameBlender object contains index to its object in this array.

Objects should allow methods to be assigned to them as well.
That’s what I use python scripts for, not really so different. A script is attached to the object and has methods that call on the object’s properties. Like I say, only you know what your doing. Myself, I find enough versatility to do everything I need.