1
$\begingroup$

Normally, we activate actuators like this:

controller = logic.getCurrentController()
actuator = controller.actuators['AddObject']
controller.activate(actuator)

This activates the actuator called "AddObject" that belongs to the current controller.

But let's suppose that I want my scene manager to tell objects to delete themselves. The "End Object" actuator has to be on the object to be deleted, not the object that's doing the deleting (unlike the Add Object). I add an "End Object" actuator called "EndObject" to the object I want to end, and then I use:

scene = logic.getCurrentScene()
cont = logic.getCurrentController()
for obj in scene.objects:
    if obj.name == "Critter":
        obj.actuators["EndObject"]
        ....

... and then what? Using:

act = obj.actuators["EndObject"]
obj.activate(act)

...doesn't work because obj doesn't have a function called activate, nor anything similar that I can find.

Any ideas? Am I using "End Object" incorrectly?

$\endgroup$

1 Answer 1

2
$\begingroup$

You do not do that. It is not supposed to "remote control" objects that way.

You can indeed connect logic bricks of different objects. But this quickly ends in a chaotic mess.

You can delete objects via endObject(). In difference to the actuator this does not need to be called by a controller of the object to be deleted.

Your sample could look like this:

import bge
scene = bge.logic.getCurrentScene()

for object in scene.objects:
    if object.name == "Critter":
        object.endObject()
        ...
$\endgroup$
3
  • $\begingroup$ I suspected it was something like "you're not supposed to do that" ;-) Thanks! $\endgroup$
    – Matt
    Jul 18, 2017 at 12:14
  • $\begingroup$ Hi Monster. I really want to know :) blender.stackexchange.com/questions/97394/… $\endgroup$
    – Scheintod
    Dec 28, 2017 at 13:41
  • $\begingroup$ Yes, this is another way to deal with such a situation. $\endgroup$
    – Monster
    Jan 2, 2018 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .