How to stop spawn sound at location ?

hi , so I imported a music track in wav. format , created a sound cue , then made a simple blueprint for box overlap , spawn sound at location , this is all good , but getting the music to stop seems to be another story. The music cue is longer than I need , so I am trying to figure out how to stop it. I tried stop node , pause nodes , destroy nodes , with delays , the music just keeps on playin . Is there a way to just stop it after a certain amount of time? thanks.

You can manipulate it through the AudioComponent returned by Spawn Sound at Location. This example ends the sound after 20 seconds. Make sure to check IsValid in case the audio ends before the delay.

Does’nt work , I tried it. Maybe because music is 3 minutes long but i’m trying to stop it playing at 1 minute 50 seconds.

The length shouldn’t have anything to do with it. I just tested stopping a song that is 4 minutes long, and was successfully able to stop it after a 1 minute and 50 seconds delay.

I suspect the problem you’re experiencing is that the actor is destroyed before the Audio Component is Stopped. I simulated the problem with the blueprints below.

Stops Playing after 1 Second
This does stop playing because the Audio Component Stop is called before Destroy Actor.

Never Stops Playing
This never stops playing because the Destroy Actor is called before the Audio Component Stop is called. The difference between this and the previous blueprint is the duration of each delay.

Debugging
To figure out if this is actually what you’re running into, add an End Play event handler and print out when the actor goes away. If you see END PLAY CALLED but the audio is still playing, then you’ve destroyed the actor before calling Stop on the Audio Component.

End-Play-Event.PNG

This is the bp I been using , when I enter the box overlap to start it , it triggers a cutscene at the same time , from another trigger box for cutscene.

Try putting the End Play event print string like I showed in my previous post to see if something else is destroying this actor before the delay fires.

does the end play event nodes go on their own or should they be tied into the rest of the music bp nodes?

On it’s own, in the same blueprint graph (since you’re trying to see if the actor associated with that blueprint is destroyed before the Audio Component Stop is called).

It should look something like this:

You can copy the code below and paste it into your blueprint to get the Event End Play and Print String nodes.


Begin Object Class=/Script/BlueprintGraph.K2Node_Event Name="K2Node_Event_4"
   EventReference=(MemberParent=Class'"/Script/Engine.Actor"',MemberName="ReceiveEndPlay")
   bOverrideFunction=True
   NodePosX=-48
   NodeGuid=00FFC1D4418A15D5717252B92C75B24B
   CustomProperties Pin (PinId=E5D7FD394B5E969355042AAE6404E644,PinName="OutputDelegate",Direction="EGPD_Output",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent=Class'"/Script/Engine.Actor"',MemberName="ReceiveEndPlay"),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=97E574D34B7873708998508F4DCC4BD2,PinName="then",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(K2Node_CallFunction_11 6E022D9644A169914D4908B5CA5D8E5A,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=6AA0DF29442FA59FA1D1449C7AA85C84,PinName="EndPlayReason",PinToolTip="End Play Reason
EEndPlayReason Enum",Direction="EGPD_Output",PinType.PinCategory="byte",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Enum'"/Script/Engine.EEndPlayReason"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="Destroyed",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_11"
   FunctionReference=(MemberParent=Class'"/Script/Engine.KismetSystemLibrary"',MemberName="PrintString")
   NodePosX=128
   AdvancedPinDisplay=Hidden
   EnabledState=DevelopmentOnly
   NodeGuid=A79C651A4F4DD6FCFC61AA985D15B19C
   CustomProperties Pin (PinId=6E022D9644A169914D4908B5CA5D8E5A,PinName="execute",PinToolTip="
Exec",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(K2Node_Event_4 97E574D34B7873708998508F4DCC4BD2,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=DF99B1664B8072FB85E07180B04F8B8E,PinName="then",PinToolTip="
Exec",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=075F64324EDCED50040688BED54DA7A6,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target
Kismet System Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/Engine.KismetSystemLibrary"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultObject="/Script/Engine.Default__KismetSystemLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=952BC0B84A0B279D377EE8801FC697CF,PinName="WorldContextObject",PinToolTip="World Context Object
Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'"/Script/CoreUObject.Object"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=F50336654A374E7CDCC05FA93BCA4685,PinName="InString",PinToolTip="In String
String

The string to log out",PinType.PinCategory="string",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="END PLAY CALLED",AutogeneratedDefaultValue="Hello",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=8AF67B6F4380F69333A6D5837497AAC6,PinName="bPrintToScreen",PinToolTip="Print to Screen
Boolean

Whether or not to print the output to the screen",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="true",AutogeneratedDefaultValue="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
   CustomProperties Pin (PinId=8AD3D02E489FF2BCF6EC458CC84E6F80,PinName="bPrintToLog",PinToolTip="Print to Log
Boolean

Whether or not to print the output to the log",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="true",AutogeneratedDefaultValue="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
   CustomProperties Pin (PinId=F3B84A9C474FFA1CEAF19992DC1A267C,PinName="TextColor",PinToolTip="Text Color
Linear Color Structure

Whether or not to print the output to the console",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=ScriptStruct'"/Script/CoreUObject.LinearColor"',PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="(R=0.000000,G=0.660000,B=1.000000,A=1.000000)",AutogeneratedDefaultValue="(R=0.000000,G=0.660000,B=1.000000,A=1.000000)",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
   CustomProperties Pin (PinId=4BA5D7B3492EF275191172940E7A52AB,PinName="Duration",PinToolTip="Duration
Float

The display duration (if Print to Screen is True). Using negative number will result in loading the duration time from the config.",PinType.PinCategory="float",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="2.000000",AutogeneratedDefaultValue="2.000000",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=True,bOrphanedPin=False,)
End Object