Jump to content

[SOLVED] Replay (Restart) sound is not working


photo

Recommended Posts

Hi guys,

Looks like I am the worst user of "UNiGiNE" game engine.

I stuck on one another problem.

I want to restart (Replay) the sound. E.g. Sound file is 20.0 Seconds long and I call Replay function after 3 Seconds which should restart sound from the first frame again.

This is my script function:

void RePlay(SoundSource sound){sound.stop();sound.setTime(0.0f);sound.play();}

But this function is not giving me expected result.

I am damn sure that this function was working ( at-least was giving me expected result ) before last update.

This is the node file parameters :

sound/Samples/Units/Engineer/engineer_shot_001.oga  0  0.0  5  50  180  1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

Regards,
rakeshj.

Link to comment

Hi,

 

The problem is that sound parameters will be applied on the next sound frame (sound frame rate is about 30 fps) and if you'll stop and start SoundSource playback in one sound frame, it'll take no effect to source time.

 

The fastest way to solve your problem is just to wait about 1 / 30 second and then start playing your SoundSource instance.

 

Here is updated code:

void replay(SoundSource sound)
{
sound.stop();
sound.setTime(0.0f);
sleep(1.0f / 30.0f);
sound.play();
}

 

Also you should call this method in a thread like this:

 

thread("replay",your_sound_source_instance);

Link to comment
  • 1 year later...
×
×
  • Create New...