End sensor?

I want to have events associated with an object’s end, e.g. particle effects or the sound of the object breaking, which will trigger if a script calls endObject() on it.

(I realize I could use an End Object actuator in conjunction with an Actuator sensor, but I’m hoping it’s possible to avoid that because (a) I’m guessing Python is more computationally efficient than an actuator, and (b) programming is easier on my brain than working with too many logic blocks.)

  • Chris

what about sending a message, using python? and receiving that message subject flips a property to true?

I’d make whatever script ends the object also play the sound, or, as bpr says, send a message (either a logic brick message or a simple write into some other python module).

But to answer you question exactly as you’ve asked it:

  • iterate through every object in the scene and see if obj.invalid == True
    Caution: processor heavy

As suggested already, simply send a message when you trigger addObject. An other object can listen to the message with that subject.
Obviously the ended object will not be there anymore.

Your guess is incorrect it is the opposite. If you think about it you should find out why it is that way.

Think about if you really need all these logic. It sounds like your logic does too much.
Hint: if it is too much in Logic bricks it will be too much in Python either.

Thanks everyone! I got it to work. Instead of calling endObject, I send a message to the object, and the object does its thing and then ends itself.