Animation Callback or Listner

The basic problem I’m trying to solve is getting notification when an action is done. I have searched around and the best I can find is to create an always sensor with a pulse that checks a frame property to see if it has passed a certain value.

I could do that but my question is why should I take the overhead hit of maintaining this pulse sensor when the animation is only active part of the time.

Wouldn’t it be great if the animation of some other object sent a message when the animation passed a certain point?

Does this kind of thing exist?

Second best would be a listener object that gets created when the animation starts and destroys itself when the message has been received. I could code this but am curious if there are any examples of anything like this.

actuator sensor?

if not actuatorSensor.positive: (send message)

see if the action is still playing

if obj.isPlayingAction(layer) == True/False:
____do this

or if you want it to do something after it passes a certain frame in the animation

if obj.getActionFrame(layer) > than the frame you want.:

[Stackexchange] How to start second action after check that first one is done in bge?

Thanks guys.

Superflip, the problem with the if statement is not having control over when it is called. The solution is to call it with a pulse but that invokes the overhead I wanted to avoid (not a big deal I know but it’s the principle…)

BluePrintRandom and Monster ill experiment with that but my issue is that I’m running the animations from Python so there is no actuator to sense.

maybe you could get the action frame as a property and the use that property in a property sensor

Be careful since there is animation culling in the BGE. Once a character is off screen their animation stops playing. It restarts when they come back.
I use a timer so even off screen events are still triggered. But again be careful since animations run at a different speed to logic. You’ll need to convert the number of frames to the number of tics.
If you’re using python anyway there’s almost no overhead in a simple timer.