Download

Need a way to set up a sound that increases in speed as player gets closer

I’m trying to create a metal detector game. I need to be able to play the ping sound when the player gets within a certain distance from one of the buried objects. Then as I get closer I need it to get faster and faster until I’m on top of it, then it will play the item sound noise. How can I do this? I have tried various ways in blueprints but have not found anything that works yet.

I would find/make a function that gets the distance between the two points, then do math on the distance
and use it to modulate a trigger delay or a timeline length. Below a certain threshold, play different sound.

You can either have a very short sound that you retrigger, or one long sound(or synth note) that you modulate the fade in/out on such that it sounds like beeping.

So, I’m not super experienced with blueprints, especially when working with sound. This is what I came up with, but it’s not playing the sound at all.

That’s getting closer! It plays maybe once now, right? Consider putting a timeline(with looping event track) after beginplay, or changing beginplay to tick.

One thing you almost definitely need is the ‘map to range’ node, either clamped or unclamped(whatever works in given situation). Print out the distance-number you get now and find the range you need(depending on the scale of your world, it could be anything), then use a clamp node to convert that range into a more manageable number.

Also, I have no idea what happens if the delay-time is changed while a delayed event is already getting delayed. Sounds scary. Floats never stand still. Might be a good idea to use a delay to poll it and store it as a variable so you have more control. Maybe even round the float to an int early on, if you don’t need such precision.

Here is a picture of an older thing I did. It doesn’t work for your specific use, it’s not what I’m talking about above, and it has more clamps than necessary. But, hopefully, it’s slightly informative still.

distance3dbp.png