Hi,
i have some Probelms with initialising added Objects.
So far i used a GameObj class, wich initialises itself when the object is added and runs its code for the first time:
class GameObj(bge.types.KX_GameObject):
def __init__(self, this):
bge.types.KX_GameObject.__init__(self)
self.arguments = "whatever"
self['this'] = self
# initial
if not 'this' in own:
obj = GameObj(own)
This works, but the Problem is, if i add the object with the following code:
added = sce.addObject(obj,self,0)
the Object is a KX_GameObject, and has not been converted to a GameObj instance.
I tried to overgive the class like:
if not 'this' in added:
obj = GameObj(added)
wich actually should be the same as the added Object itself excutes this code, but i get an Error.
def main(cont):
own =cont.owner
if cont.sensors["Always"].positive:
if not 'this' in own:
obj = GameObj(own)
Hopefully someone can understand my problem and has some hints to solve it…
The goal is to add an Object, overgive it a class and initialise it, and then access direct to its content, without running a code from the Object itself.