Question about npcs

How can you make it so npcs respond to sounds around the map. Is it possible?

1 Like

You could have an event fire each time a sound is played. The callback function would first calculate the magnitude between the NPC and the place where the sound is played. If it’s close enough then, do something.

You can check the playback loudness and make them respond to the values.
You can also check all sounds to see which are playing and make it respond.

1 Like

“Responds to sounds around the map”?

Do you mean something along the lines of player fires weapon, NPC registers the sound, and the NPC walks towards the player?

You could always use GetPropertyChangedSignal to listen for a change in [sound].Playing and set up a cache of sounds and what player they originate from.

Alternatively, if these NPCs are only supposed to process sounds that will exist upon server creation, you could just log those in a table that makes reference to the sounds origin.