Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping a sound til player exit level
ExpectedIdentifier Offline
Member

Posts: 234
Threads: 10
Joined: Sep 2012
Reputation: 11
#2
RE: Looping a sound til player exit level

(07-19-2013, 07:59 PM)Hauken Wrote: Hi, im trying to create some athmosphere regarding sound, this is what i want:

The player walks into an area trigger and activates the sound, it plays at once, then 10 seconds after it plays again and again til the player leaves the level.

From my perspective:

Onstart calls a function that tells void func sound that we're gonna loop this but the function says - not until the player walks in my area but when he do i will call the next function which plays a sound, the onstart code says we're gonna play the sound after 10 seconds again.

---

As it is now the game doesnt crash but it doesnt work either, I've followed the "For" Loop tutorial in the wiki.

What's wrong here?

Also I want to mention this is the first time I'm using loop commands.

PHP Code: (Select All)
void OnStart()
{
    
//Looping athmosperhic sound
    
{      
        for(
int i 0<4i++)
        
AddTimer("S1" i10 i"func_sound");   
    }
}

void func_sound (string &in asParentstring &in asChildint alState)

{
AddEntityCollideCallback("Player""sound_scare""func_sound"true1); 
}

void func_sound(string &in asTimer)

{
string x asTimer;
    if (
== "S1")
    {
        
PlayGuiSound("door_level_cistern_open.snt"0.5);
    } 


Your code seems far too complex for what you're trying to achieve... wouldn't something like this do the trick?

PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player""AreaTrigger""PlaySoundLoop"true1);
}

void PlaySoundLoop(string &in asParentstring &in asChildint alState)
{
AddTimer("SoundLoopTimer",0,"SoundLoopTimer");


void SoundLoopTimer(string &in asTimer)
{
PlayGuiSound("door_level_cistern_open.snt"0.5);
AddTimer("SoundLoopTimer",10,"SoundLoopTimer");


Maybe not the best/shortest coding for the problem but it'll work.

Closure ModDB page:

[Image: 16LO8Sx]
07-19-2013, 08:41 PM
Find


Messages In This Thread
Looping a sound til player exit level - by Hauken - 07-19-2013, 07:59 PM
RE: Looping a sound til player exit level - by ExpectedIdentifier - 07-19-2013, 08:41 PM



Users browsing this thread: 2 Guest(s)