-2
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ You could fake it. Just test to see if the enemy is within a certain radius; if they're moving play a sound file. Most games don't portray realistic stepping sounds every time a foot hits the ground. Load up any first person game and test this out yourself. I guarantee you that most steps take place without an actual sound effect playing. \$\endgroup\$ – Krythic Nov 15 '16 at 15:32
1
\$\begingroup\$

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:

  • Configure the loudness of a given entity (e.g, a larger creature like Tyrant from RE would make noise sooner than a lowly zombie)
  • Query entities near the player using whatever means makes sense for your game (I'm currently using the spatial partitioning data for this), using the loudness as a threshold for the range of the query (similar to how I might implement a ranged non-projectile attack)
  • If the entity is in range, play the footstep sounds at a loudness based on an appropriate conversion of 'distance from player' <-> 'actual sound volume'

Based on player:

  • Have the player have some form of 'hearing range' configured
  • Detect all entities within that range
  • Have those entities play footsteps at a given volume based on their distance from the player (convert the range to a logarithmic representation of the audio volume you desire)

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.

\$\endgroup\$
1
\$\begingroup\$

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    

Etc.

[EDIT 1]

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

\$\endgroup\$
-3
\$\begingroup\$

that's totally a "tons" of work , but i can give you list-to-do to make it

  1. Detect area where the npc
  2. Calculate the range from player to npc
  3. set the volume based on range

i cannot give example sorry because its not just one or two , its THOUSAND OF WORK .

\$\endgroup\$
  • \$\begingroup\$ is it ironic??? \$\endgroup\$ – realUser404 Nov 10 '16 at 15:46
  • \$\begingroup\$ English, please learn it. \$\endgroup\$ – Krythic Nov 15 '16 at 15:29
  • 1
    \$\begingroup\$ @Krythic there's no need to be rude, the answerer is clearly not a native speaker and yet tried to write an answer to what we can only hope was the best of their ability. Writing in a second language is hard, and they don't need to be mocked for not coming across as fluent. More constructive criticisms would be more welcome. \$\endgroup\$ – Trotski94 Nov 15 '16 at 17:03
  • \$\begingroup\$ @JamesTrotter is still a weird answer non-the-less, I mean, it's not that much work, directional sound is built into URE4 and thus is not a lot of work, but yae, Krythic das rude... \$\endgroup\$ – Grey Nov 16 '16 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.