EndObject in python

When using the edit object actuator one can add an object or end an object.
While adding an object using python only is easy[BGE.logic.getCurrentScene().addObject(object, loc, 0)], I can’t find a code to end the object.

Any help?

Thanks, bearmey

object.endObject().

You don’t need the extra stuff on the addObject() function - just addObject(object, ref) would do. By the way, ref can be a reference object - the created object will have the reference object’s position and rotation.

Ya, about the addObject I just used it off the Internet and never bothered to look in depth on it so I just left it on.

Also terminal(or command prompt on pc) says attributeError: ‘KX_Scene’ object has no attribute ‘endObject’

I’ll using it in the same context of addObject() just changed to endObject.

Any help?

Thanks, bearmey

No, it’s object.endObject() - the function is stored in the object itself, so:

cont = logic.getCurrentController()
obj = cont.owner
obj.endObject()

In Blender 2.5 will work.

So if a add a new object using .addObject how can I end that object without ending the original object.

obj = scene.addObject(...)
obj.endObject()

greetings,
moerdn

moerdn is correct - the addObject function of the scene returns a pointer to the newly created object, which you can then use to manipulate that object.

No errors come up anymore but the object still does not end.

Any help?

Thanks, Bearmey

Thanks, so much I found I was adding twice and deleting once.

It works!!!

Thanks, bearmey