Suppose I have 2 cubes, cubes A and B. Only A is visible because Cube B is on the 2nd scene. On object A I have a keyboard sensor and add object actuator which adds object B. And it works perfectly. The Second Cube will appear
The bad thing is I have to put another script/ sensor on object B itself to end it. Since the end object actuator doesnt allow you to select a object. It must be place on the object you are ending. Object B.
Is there a way maybe thru python I can end Object B from object A, where I have the addobject script to begin with?
Yep, it’s actually very easy. After spawning the object, you can get and end it with a pointer to the object:
from bge import logic
sce = logic.getCurrentScene()
cont = logic.getCurrentController()
obj = cont.owner
if not 'init' in obj:
obj['init'] = 1
obj['objectb'] = sce.addObject('ObjectB', obj)
# When you want to destroy object B
obj['objectb'].endObject()
This script doesnt have the problem of the add object actuator when it adds a cube with a empty parented to it.And the empty parented to the cube has a add object actuator on it that adds a cube the cube gets bigger.If it does do this without error could i have the script please solarlune?
Oh this was solved, btw this worked for me I was just unable to use it because I had to specify the object in the script. But it taught me how to use it.