Playsound2d plays tiwce :/

Hello Experts !

I want a sound to be layed when I enter a triggervolume, so I put the following script :

The problem is that when I leave the volume and go back inside just after, while the sound if still being played, il launches a second time the wav file and I have twice the same audio being read… and if I move out and in again it will be three times :confused:

Any ideas please on how to avoid that ?

Hey @KALRYSSIAN!

Are you only wanting to play the sound once ever? Have you tried using a do once node?

If there are other factors that need to be taken account for let us know!

Hello !

The problem with the ‚Äúdo once‚ÄĚ is that he will never hear the sound again :frowning: I want each time that the player enters the trigger volume that the sound gets played, but just never more than once‚Ķ :frowning:

Hey @KALRYSSIAN,

That’s not a complicated fix. So what you will need to do is reset your node once you leave the volume, but what you are most worried about is not having the audio play more than once right? One example on how to do that is to set a timer to reset a variable allowing you to play the sound again once it has been reset, but more specifics may be needed to figure out exactly what you need:

Hello Sir,

Thank you fore your help !

To sum up what I need :

  1. When I enter the volume, it plays the sound
  2. Even if i leave the volume, the sound needs to continue to be played
  3. If I enter the volume and the sound is still being played, nothing happens : it continues playing
  4. If I enter the volume when the sound is finished, its plays again

Is it clear ? :slight_smile:


Here is an implementation with the sound duration. Set isPlaying default value to false.

1 Like

Hello !

I have done exactly as you said :

And here is the detail of the sound :

Unfortunatly, when I enter the volume nothing happens, no sound is played ‚Ķ I have even added a ‚Äúprintstring‚ÄĚ after the ‚Äúclaerandinvalidatetimerbyhandle‚ÄĚ to check if the is going to be displayed, but nothing is displayed‚Ķ

Help :frowning:

Edit : It works !!! The boolean had to put be by default to ‚Äúno‚ÄĚ

You ROCK guys :slight_smile:

You seem to be using a full actor overlap event. Does the actor have a collision component (box, sphere, capsule). Does the actor & component have ‚ÄúGenerate Overlap Events‚ÄĚ turned on?

I personally prefer to add a box trigger and use on component overlap.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.