I am making a horror game and I have NPCs roaming around the map.
How can I make it so the player can hear the NPCs' footsteps as they get closer?
I'm not a UE programmer, so I can't help with code specifics.
That said, I've had this same requirement come up in one of my own projects, and figured out two approaches I'd use, depending on your actual needs:
Based on entity:
Based on player:
It's a fairly easy thing to implement, the only thing I've personally tripped over with doing it is realizing that volume is NOT a percentage in a lot of cases, and converting to the appropriate scale isn't always straightforward.
I would suggest adding some logic like this:
Let D be the distance between Player and Entity in UE units
Let X be an arbitrary multiplier to determine volume (suggesting a min of 0 and a max of 2), the higher X, the lower the overall volume
And let V be the volume of the entity's footsteps in (from 0 to 1)
V = 100 / (D * X)
X = 0.5:
D in units V X=0,5 100 2 200 1 300 0,666666667 400 0,5 500 0,4 600 0,333333333 700 0,285714286 800 0,25 1000 0,2 2000 0,1 3000 0,066666667 4000 0,05 5000 0,04
X = 1
D in units V X=1 100 1 200 0,5 300 0,333333333 400 0,25 500 0,2 600 0,166666667 700 0,142857143 800 0,125 1000 0,1 2000 0,05 3000 0,033333333 4000 0,025 5000 0,02
another suggest I came up with: Another way of doing this is to simply get the location of the entity and place a sound on it's location, you could do this in the blueprint, and would result in a much realistic sound, you only need to set the volume value of the sound and the engine should calculate it's volume and direction automatically