Which performs better: onActorBeginOverlap or NotifyActorBeginOverlap?

Hi,

I do often find myself in contexts where I could opt for either binding a function to onActorBeingOverlap or just overriding NotifyActorBeginOverlap.

Is there any performance gain, or any other type of advantage, in using one approach over the other?

Are there “best practices” that can help me in my choice of implementation?

Cheers
f

Hello! In fact they are called in the same manner and in the same place =) You can check that here https://github.com/EpicGames/UnrealEngine/blob/f20ba8cdd31ffb1f3a4d821e6db7114b8f94f558/Engine/Source/Runtime/Engine/Private/Components/PrimitiveComponent.cpp#L2687

As for differences - virtual func can not be disabled but you are free to unsubscribe from delegate )

Dear valued Unreal Engine user,

This seems like it would really depends on the use case. An ideal solution, wherever possible is to minimize the number of function calls and then iterate on an arrays of data inside that one function, as that would be better in terms of cache and function call overhead.

Using a virtual function is likely to be cleaner in C++, as you do not need to write code to bind it at runtime. In terms of performance the difference seems likely to be minimal, unless there are multiple functions bound to the same delegate or you have many, many actors that are all overlapping. If it were the latter case, then using a single function to iterate over all the actors at once would likely be a better optimization.

If you are interested, you could try to profile this either using the CSV profiler using a scoped timing stat or using Unreal Insights.

Unreal Insights Reference in Unreal Engine 5 | Unreal Engine 5.1 Documentation.

Thank you for your continued support,