SFX Beeps Faster As Player Gets Closer

I have a metal detector I want to create, and I want the sound cue to increase in speed by repeating faster when I get closer to the object. What do I do?

I have two blueprints, one for the object detecting and one for the metal detector.


1 Like

Code for the detector

1 Like

ClockworkOcean beat me to it, since I was adding detection stuff too.

This is on the player char itself, so adjust the self reference as needed:

For whatever reason, I get errors referring to the delay. Is something supposed to change?

Also I think I referenced the “detected item” wrong. What am I supposed to do?
image

Ok, you have to actually set the detected item. Just being the right type is not enough…

On begin play in the detector, you can use ‘get actor of class’ to set the item.

You also need to set the 4 variables to something sensible, otherwise it will just beep like crazy…

This is the code for my detected item blueprint so far.

This has always been the thing I’ve never quite understood how to do.

The beauty of my method, is the detected item can be totally empty :wink:

That does help!

What shall I do about this little thing then?
image

Keep it

The thing on begin play, is just to set the reference.

Even though I probably did it wrong?

I need more of a clue. What are you basing this on? Can you show me the whole detector BP?

Here ya go

You still haven’t set the variable! :slight_smile:

image

Do I need to set this to detected item ref?

(I’m learning as I go here)

1 Like

Yeah :slight_smile:

Does it work yet?

Not quite, The audio plays every 3 seconds as it’s what I placed in the lerp, never faster or slower.

I think you said something about these variables in the lerp and clamped. I didn’t touch those just in case.

Ok so some sensible settings would be

Shortest distance 250
Longest distance 3000
Shortest beep time .25
Longest beep time 3

It’s not doing anything at the moment, because 10 is basically right on top of the item, you need to set it in the thousands so you can approach it from far away.

Nice code, very similar (but better) that what I need for a resource node detector!

1 Like

I placed numbers inside, it just doesn’t seem to beep faster or slower as I change the distance.
I still feel like I’m doing something wring here.

I can’t see anything else obvious that it could be.

See my post above :wink:

Longest needs to be at least 3000 ish…