2 registered members (Akow, SBGuy),
1,423
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Sound when it's close enough
[Re: vlau]
#75476
05/25/06 13:32
05/25/06 13:32
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
I'm guessing that your model is doing a looping sound? Here's how I'd do it... Code:
sound SkelVoiceSND = <Voices.wav>; // The sound file... var SkelVoiceVol = 200; // Change the volume here! var SkelVoiceHandle; // Action SkelVoices { while(1) { if (vec_dist(my.x, camera.x) <= SkelVoiceVol * 10) { if (snd_playing(SkelVoiceHandle) == 0) {SkelVoiceHandle = ent_playloop(my, SkelVoiceSND, SkelVoiceVol);} } else { if (snd_playing(SkelVoiceHandle) == 1) {snd_stop(SkelVoiceHandle);} } wait(1); } }
This action will play the sound in a loop while the camera is close enough. It uses camera, instead of player (or whatever), because the camera is what determines the sounds volume and other properties. This action will also stop playing the sound if the camera is out of the range of hearing it. I have not tested this, so it may not work, but it should... I hope. Anyways, let me know how it goes... xXxGuitar511...
xXxGuitar511 - Programmer
|
|
|
Re: Sound when it's close enough
[Re: xXxGuitar511]
#75479
05/25/06 20:23
05/25/06 20:23
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Oh...... i get it..... The code I posted works fine... However, it's made for looping, which is what I thought you wanted... Here's some code that only plays it ONCE. Code:
sound SkelVoiceSND = <Voices.wav>; // The sound... var SkelVoiceVol = 200; // The volume...
ACTION SkelVoice { my.skill1 = 200; // Distance from player... while(my.skill1 > 0) { if (vec_dist(my.x, player.x) <= my.skill1) { ent_playsound(my, SkelVoiceSND, SkelVoiceVol); my.skill1 = 0; } wait(1); } }
xXxGuitar511 - Programmer
|
|
|
Re: sound code
[Re: aslam]
#75482
05/28/06 10:04
05/28/06 10:04
|
Joined: Apr 2006
Posts: 41 Nokia
Sunangel
OP
Newbie
|
OP
Newbie
Joined: Apr 2006
Posts: 41
Nokia
|
Quote:
(just got from the same forum) but the problem is that commentary just starts running with the start of the game. Is there anybody who can help in the regard??
I still got the same problem, that the music starts at the same time as I get the level 'on'.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|