Jump to content

Triggering a .wav


7H3V1RU5
 Share

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.)

-7H3V1RU5

Link to comment
Share on other sites

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.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

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.

Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)

Link to comment
Share on other sites

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;

}

 

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

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.

Guest
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.

 Share

×
×
  • Create New...