I’m working on a project where I would benefit from a way to respond to actors being attached to something. The only way I found was if I have a custom root component that overrides OnAttachmentChanged but this is one of the things that you usually realize later and it’s a lot of work to change a blueprints root component to a derived class since you can’t change it but rather replace it.
Currently, USceneComponent::OnAttachmentChanged() is a virtual function with an empty default implementation. If a delegate was added even if it’s not a blueprint accessible one it would allow owning actors to react to being attached and detached which I often missed. Is there a performance reason this is not a thing because I would assume a check for a bound delegate and subsequent call to delegate wouldn’t add that much overhead?
I’m thinking of modifying our engine to add it but wanted some input.
To speculate on why we don’t already have a delegate there, I assume that giving extending classes the ability to override `OnAttachmentChanged` has been sufficient for our and licensees’ needs so far.
Attachments happen rarely enough (especially at runtime) that I don’t foresee adding a delegate having a perceivable effect on performance. If you want to be able to respond to the attachment of any scene component, I would just add a delegate to that virtual function if it were my project. It’s a small and safe engine modification.
It would be a good way for others to indicate their desire for this change at least! If you create a pull request, add the link here so other future answer seekers can vote on it
Thanks for the answer. I’ll do that. Do you think this is something that would warrant a pull request? It seems like a small, safe change and could be a nice addition for others as well.