Download

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.
BallBounce.JPG

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.
084f1e3a923420f2e5a4bdd18f1809b6a1c27d0a.jpeg

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
8f8172a8d4862e45648ebb94c75542059d34e115.jpeg
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.