How to simulate an efficient OnAttach/OnDetach event?

I am looking for a more efficient way to simulate an OnAttach event.

At the moment I have only managed to do it in the following way.

But I think this way is very inefficient because it is using the “Event Tick” and it has a delay.

I only need to know three things:
1-The exact moment in which the actor is attached
2-The current parent tag
3-The old parent tag

Any ideas to do this in a more efficient way?
Thank you so much!!

I can’t find any better way other than making a native component subclass for your RedCube and overriding virtual function OnAttachmentChanged.

However, this may be partially justified - afaik the engine doesn’t attach/detach components on its own, meaning every time an attachment changes, it is done from your code. If that assumption is right, you could easily create your own event dispatcher, and replace your attachment calls with a wrapper function that does the attachment AND triggers the dispatcher.

1 Like

Ok, I understand, thank you very much for your help!! very appreciated!!