I want the debris to cause damage, when it hits the player. Is there a way to get the hit events?
Yes, you can use collision detection to detect when a piece of debris hits the player and then apply damage to the player. Here are the basic steps to implement this:
- Add collision to your debris object: You need to add collision to your debris object so that it can interact with other objects in the world. In the editor, select your debris object and in the Details panel, click the Collision dropdown and choose the type of collision you want to use (e.g. Box Collision, Sphere Collision, etc.). Adjust the collision shape to match the shape of your debris object.
- Add collision to your player object: Similarly, you need to add collision to your player object so that it can detect when it is hit by debris. Select your player object and add collision as described in step 1.
- Set up collision detection: In order to detect when the debris collides with the player, you need to set up collision detection. Select your debris object and in the Details panel, scroll down to the Collision section and check the “Simulation Generates Hit Events” checkbox. This will generate hit events when the debris collides with another object.
- Handle the hit event: Now that you have collision detection set up, you can handle the hit event in your player blueprint. In the event graph of your player blueprint, add an OnComponentHit node and connect it to the logic that applies damage to the player. You can use the Other Actor output of the OnComponentHit node to get a reference to the debris object and apply damage to the player based on the properties of the debris object.
I get the Hit Event for the GeometryCollectionActor (aka destructible) but the velocity is null. I get the same Hit Event when I just walk onto the fragment (not sure if debris is the right wording, I am no native English speaker).
For me it is important to differentiate between fragments that fall from above onto the player and fragments that just lay on the ground, so I need the velocity and mass here. For projectiles and other actors it works fine, it just seems to be a problem for GeometryCollections