Jump to content

Triggering a .wav

Recommended Posts

Hey everyone. Here again. With another questions. I'm sure not the last time.


I started with Qbasic and am slowly learning c++ and .lua.


I was wondering if anyone had a script where;


player touch-->call .wav file


(I know this is probably the most basic way of saying it, so I hope you all can understand my request.)

Share this post

Link to post

Easiest way to do this is lua.


self.sound = Sound:Load("Sound/Player/Footsteps/concrete1.wav")
function Script:PlaySound()--in


You can use the Flowgraph or have a trigger that emits the sound on Collision.

Share this post

Link to post

Leadwerks already comes with the necessary scripts:


CollisionTrigger.lua -> attach this to your trigger brush

Noise.lua -> attach this to a pivot - your sound source location on the map


Set Playing to false in Noise script and do a Flowgraph link between Trigger brush's Collision() function and Noise script's Play() function.

Share this post

Link to post

Works great!!!!


Now I want to make it to where it only plays that .wav file on the first collision. Is there a code for -stop after play=1? And not sure how to make it only play the sound once.

Share this post

Link to post

To play a sound once you can set a flag outside of your main loop. In c++ it could be


bool soundplayed = false;


Then in main loop put if (soundplayed == false)



soundplayed = true;



Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...