Bouncing Ball Sound

I was having a problem with a bouncing ball effect in my game and was surprised to find very little advanced sound tutorial’s on the subject. One’s that I cound understand anyway. The main problem I was having was when the ball would rest on the floor. The event hit I set up on the sound didn’t know the difference between a bounce and resting so it infinitely looped the 1st part of the sound. I found a work around using an unbind (Below) only problem is it would only make a bounce sound once.

Ok so how do you fix this? 1st off make an Actor BP, add a static mesh and put your ball in there. Next you need to find out how much force the ball makes when it bounces. Set up the below BP by pluging the wire from your vector length into the “In String” entry of the “Print String” node. When you play your scene and drop the ball to the floor in the top left corner you will see a number flash up very briefly when the ball bounces. Make a note of this number. A moment later when the ball is resting on the ground (This is where the problem is occurring because the blue print doesn’t know when to end the sound so the start gets stuck in a loop.) you will see another number.

When you have your two numbers you can then pull out the wire from the impact normal vector length again and search for “>” and pick the one that compares two float values (by default the first one when context sensitive is turned on). Take a look at the below BP
You can’t use a get actor location because the ball is a static mesh and a static mesh is not compatible with an actor reference. Thats why you have to use Get Socket Location. In the “>” node make sure the number you put in is above the number you got when the ball is resting on the ground and below the number you get when it bounces. You can see in mine I put 10 but the number you see might be wildly different because I have the weight of my ball set very low. The great thing about this BP is that it can be used on so many different types of situations from glass breaking to a cup falling off a table. I used the mesh itself for the event hit if you are using a capsule then make sure to set the capsule to be slightly larger than the mesh or be sure to turn off collision of your mesh.
Thanks to Erasio for helping me with this.

1 Like

@tcla75 Thanks so much! Even though the original screenshots are no longer shown, your technique was still very helpful! In my case, I used the “Distance” pin on the Break Hit Result node and used a Float “>” Float node set to 0.5 and connected to a Branch node to make sure the sound only played if this “Distance” (from the start of the trace to the Hit Location) was greater than 0.5. Screenshot attached: