Hit Events From APEX Destruction Chunks

I am specifically interested in getting OnComponentHit or EventHit responses when a CHUNK of a destructible actor is involved in a blocking hit.

My cursory search on UDN found a few unanswered questions with similar titles and a slew of bug tracker issues that seem related:

A few of these are related to impact damage being disabled. I am fine with enabling impact damage in this particular instance; though that is a nuisance if you want hit events regardless of impact damage being on.


Research

The arresting factor I’ve found is inside the function FPhysScene::DispatchPhysNotifications_AssumesLocked where NotifyInfo.bCallEvent0 is false when NotifyInfo.Info0.Actor is a destructible actor.

The source of that value is In FBodyInstance::AddCollisionNotifyInfo. Where the bBody0Notify boolean is set to (FilterFlags0&EPDF_ContactNotify) != 0 where obviously the constant EPDF_ContactNotify is unmatched in the bitfield.

Perhaps there is some way for me to force the FilterFlags value to enable that bit in the bitfield? My attempt at calling SetMaskFilter(EPDF_ContactNotify) on the destructible component’s body instance didn’t change the bits set on the body instance returned by Body0->GetOriginalBodyInstance(Shape0) which are assigned to FilterFlags0 so perhaps attempting that on a destructible component directly isn’t doing what I expect.

Questions

  1. Is there an out of the box solution that will get me hit events on individual apex chunk blocking hits?
  2. If there isn’t something out of the box could you point me towards the engine source where I could make a change?
  3. It was mentioned in a previous question of mine that there is a new destructible interface forthcoming (Blast) is that being released soon?

With regard to the last question it’s been challenging to search an issue and find an entry in the bug tracker marked backlogged or won’t-fix because new features are coming soon but with no release date announced.

Hi Connor,

There’s nothing as simple as just getting the chunk from a collision, but there should be two fields on FHitResult that will identify what was hit. BoneName should have some identifying information in it, as will Item. Item looks like it gets the chunk index which is populated in SetHitResultFromShapeAndFaceIndex in CollisionConversions.cpp. So if you can get the apex actor you should be able to extract your chunks from there.

Benn.

Hi Benn,

Your answer doesn’t precisely solve my issue. I want to get hit events to fire on the destructible actor that has chunks hitting any surface.

If I followed your answer I could see adding the response logic to any surface that might get hit by a destructible and firing some event BACK to the destructible that I am interested in having events on but that would be costly and counter-intuitive.

Hopefully you can point me in the right direction.

Sorry Connor I understand now. Have you attempted binding to OnComponentHit or using AActor::ReceiveHit. Those should get you callbacks when the component or actor hits another, with a quick test I was able to track which chunk of a destructible a player was standing on after destruction.

I’ve binded to both and I can get events when an object intersects with a destructible chunk. However I am more interested in getting a hit event when the chunk is flying around and hits any arbitrary object.

Sorry for the delay, I think I can see why the notify flags aren’t set up correctly. In UDestructibleComponent::OnCreatePhysicsState there’s a call to CreateShapeFilterData which sets up the filter flags. We pass bEnableImpactDamage as the parameter for enabling the notify flag. A quick way to test would be to enable impact damage on your mesh and see if you’re getting more event callbacks.

If this works then you’ll need to change the flag passed to CreateShapeFilterData and possibly make a change to the code which catches the impact damage events if you don’t want that to be enabled (UDestructibleComponent::ApplyDamage and UDestructibleComponent::ApplyRadiusDamage)