7H3V1RU5 Posted September 7, 2015 Share Posted September 7, 2015 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.) Quote -7H3V1RU5 Link to comment Share on other sites More sharing options...
reepblue Posted September 7, 2015 Share Posted September 7, 2015 Easiest way to do this is lua. self.sound = Sound:Load("Sound/Player/Footsteps/concrete1.wav") function Script:PlaySound()--in self.sound:Play() end You can use the Flowgraph or have a trigger that emits the sound on Collision. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Olby Posted September 7, 2015 Share Posted September 7, 2015 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. Quote Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64) Link to comment Share on other sites More sharing options...
7H3V1RU5 Posted September 8, 2015 Author Share Posted September 8, 2015 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. Quote -7H3V1RU5 Link to comment Share on other sites More sharing options...
cassius Posted September 11, 2015 Share Posted September 11, 2015 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) { mysound->Play(); soundplayed = true; } Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.