How to detect a sphere collision "hitting" vs "rolling"?

Let’s say I have a sphere physics actor and a hollowed out box and the sphere is moved around in the box.

For the purposes of playing “hit” or “rolling” sounds, how can I detect when the ball has impacted on a side of the box vs when it’s just rolling around inside the box?

It also occurs to me that the ball could be rolling along the floor of the box and then hit one of the sides which prevents you from doing something like testing if the ball was touching the object in the previous frame.

I tried using “Simulation Generates Hit Events” but that seems to generate events not just when an impact occurs but also as the ball rolls or slides along a surface.

What’s the proper way to accomplish this?

Thanks!

Hi!

From the collision callback you should be able to retrieve useful information about it, including the impulse amplitude. The impulse should be bigger for a direct hit than for a simple rolling event.

In the same way, you should have a look at the friction impulse in order to filter out sliding events.

1 Like

Hi thanks! I have a blueprint that seems to be working for playing impact sounds. Here’s a screenshot…

I have a couple of follow up questions:

In the blueprint version of OnComponentHit there is a “Normal Impulse” that corresponds I believe to what you refer to as impulse amplitude but I’m not sure what I should refer to check what you call “Friction Impulse”. Is this something that’s not accessible in blueprints?

Secondly do you have any suggestions for implementing the rolling detection? I can see where if there’s a hit and imulse aplitude is low, then the ball is rolling but what event would I check to determine when the ball is no longer in contact with a surface? Perhaps OnEndOverlap?

2 Likes