Sound in behaviour tree

Hello everyone, I am pretty new to UE4. I have developed the behaviour tree below for a project, but something is wrong with the sound.

When the player does not shine flashlight on the AI but is seen by it, it will play a sound, wait for 5 second, and play the sound again. If the player flash the light on AI while the sound is playing, I thought the sound would stop, but it keeps on playing until the end.Therefore, I was wondering if anyone could help me figure how to stop the sound from playing when the “inLight is set” branch is executing? The sound file is 4 seconds in length.

Thank you for the help! :slight_smile:

The best way i can think of to do that, is to add an AudioComponent to your AICharacter blueprint, and choose the sound you want to play in it.

When you want the sound to start playing, you call the AudioComponent’s Play method, and when you want it to stop, you call the Component’s Stop method. You just have to call those methods in your Behavior Tree blueprint.