Component Begin and End Overlap firing together, continuously

Update -

I managed to track down this issue to the InstancedMeshComponent I was using as the parent for my Interactible Component, after stepping through the debugger.

The flow goes like this:

  1. UPrimitiveComponent::UpdateOverlaps() gets called for the ‘trigger volume’ component and detects the overlap with the InstancedMeshComponent.
  2. This is a new overlap event, so UPrimitiveComponent::BeginComponentOverlap() is called
  3. Inside BeginComponentOverlap() the new overlap event is broadcast to the InstancedMeshComponent
  4. At this point, both components have recorded the overlap and everything is as expected
  5. UPrimitiveComponent::UpdateOverlaps() is now called for the InstancedMeshComponent
  6. Detecting overlaps internally eventually calls UPrimitiveComponent::ComponentOverlapMultiImpl() on the InstancedMeshComponent, which is where the bug occurs.
  7. InstancedMeshComponent does not store it’s collision information in UPrimitiveComponent::BodyInstance. Instead it uses it’s own separate container so it can have multiple body instances. However, it does not override the virtual function UPrimitiveComponent::ComponentOverlapMultiImpl() to correctly use the BodyInstances it is maintaining.
  8. Since UPrimitiveCoimponent::BodyInstance is invalid, there is no overlap, and an OnComponentOverlapEnd event is generated.
  9. 1-8 now repeat again the following frame.

This seems like an UE4 bug to me with how InstancedMeshComponent is currently implemented.

My Solution:

My solution to avoid this problem is to not used the InstancedMeshComponent as the parent of my Interactible Component in the first place. It never really made sense anyways, but I was trying to avoid making a custom C++ component. But alas, I created a C++ component that derives from the box component and is Blueprintable, and now everything works as expected.

Final Thoughts

There really should be Blueprintable components that derive from UPrimitive much further up the chain than UInstancedMesh (mesh, box, etc.). I can see many common scenarios where making a custom Blueprint Component that has collision information would be extremely useful/required. Is there some potential danger with exposing some of those base components to Blueprint, or is this maybe just an oversight?

3 Likes