How can I use ReceiveHit to determine what object was hit?


I’ve been testing AActor::ReceiveHit. I used the new Rolling Ball template in C++, created a new AActor subclass and attached the beach ball static mesh to it (so I have 2 balls in this level, the main Character and this ball). I start the game by dropping it from the air. Each time anything hits this ball - the floor, pushed cubes, the main Character/Beach ball - it produces a hit. It was easy to filter referenced objects like the actual Character ball. But what if I wanted to identify the floor and fire a “beep” sound from it on each hit ?

The floor is a StaticMesh, dropped into the scene, not part of any defined class or blueprint: can I get a reference from it in C++, through a C++/blueprint interface that could pass some identification at startup to my subclass? Or do I need to create a specific AActor subclass for it so I can filter it out ?

As a side note, I tried with bSelfMoved thinking that it went TRUE if the opposing object did not have any velocity, like hitting a floor. But no, even hitting the floor after a drop makes bSelfMoved == true. I’d love more information on that parameter.


Hi DrHobo,

Have you considered using Physical Materials? You can use the hit result to determine what physical material was hit, and then use that to determine what happens with the hit.

This must be investigated at once. :slight_smile:

Zak Parish has many tutorials on materials but none on physical materials.

Tesla did a tutorial on physical materials
Unreal Engine 4 Tutorial - Physical Materials - YouTube and he concluded that custom materials could be build and composed in blueprint to add additional physical properties and sound. So I’ll need to dig in a little more into it.

A very good tip, sir. Thanks.