about events, delegates & parameters

Hi, I need some help with this. I don’t understand how I am supposed to use event-handlers the way I need to, if the parameters are strictly defined.

I have an audio component. When it stops playing, I want to destroy the actor it belongs to. With particles I can do this, because the finished-event takes the particleSystemComponent as a parameter. So I can use a delegate to call component->getOwner()->Destroy().

But the audioComponent’s finished-event handler doesn’t take any parameters. So, as far as my understanding goes, I would have to use a delegate that is a member-function of AudioComponent in order to get a “this-reference” that I can use instead. But I can’t add any members to that class…

What can I do here?

I’d have the owning actor listen to the finished delegate and then destroy itself when it triggers.

I’m not sure what you mean by “listen”. Are you suggesting I create another type of event to be used inside the delegate where the actor can register itself? Can you give me an example?

In your custom actor that dies on sound end, in it’s begin play method, have it register for the sound’s finish delegate and then destroy that actor when it is triggered.

I see. Thanks. The thing is I didn’t use a custom actor for this, but I guess there’s no reason why I shouldn’t.