• How do you emit a sound from a player through a trigger?
    3 replies, posted
I'm looking for a way to emit a sound effect from any user that touches a trigger. I've been trying all sorts of methods but none of them seem to work well if at all. Basically what I'm trying to achieve is whenever a player activates a trigger a sound will be emitted from player/origin of the player. Other people need to hear it as well and should work for multiple users close together. Does anyone have any ideas as to a method that works well?
In the ambient generic, have you tried setting the Source Entity Name (last parameter) to !activator if the player touching a trigger do PlaySound on the ambient_generic, he is the !activator, so it should play from his location
I tried setting the ambient_generic's source entity to !activator, Unfortunately that doesn't work. Also as far as I know there is no way to change an ambient_generic's source entity from an input so that's not a thing. The closest thing I have is using an env_microphone to broadcast the sound and change the speaker entity to !player with the trigger which works; However, it continuously broadcasts the sound to the speaker and if the speaker changes mid-sound it doesn't reset the sound and it just cuts it off for the first user so that's not really what I want but I'll use it if there is no other option. I've also tried using a lua_script but the lua_run entity doesn't work at all with valve's I/O system so running lua commands is impossible as far as I know. It just feels like every little thing I want to do in this engine is either really easy or impossibly difficult to figure out...
Lua_run works just fine but most of the time if the map is running on a server is blocked so I wouldn't recommend that. I think the source entity option is good. !activator doesn't work as the trigger that fires the input to play the sound is the activator not the player. You could set the source entity to something like "sound_emitter" and have the trigger do the following: Onstartouch>!activator>addoutput>targetname sound_emitter Onendtouch>!activator>addoutput>targetname none Onstartouch>ambient_generic>playsound>delay 0.01
Sorry, you need to Log In to post a reply to this thread.