TOUR
PRICING
HELP
Stencylpedia
Blocks Guide
Sample Games
Developer Center
FORUMS
CHAT
#MADEINSTENCYL
EDUCATION
SIGN IN
×
Welcome back!
Username or E-mail
Password
(
Forgot?
)
C
OMMUNITY
Home
Issue Tracker
Inbox [0]
New Posts
New Replies
Search
Stencyl Community
→
Stencyl
→
Ask a Question
→
[SOLVED]Sound Effect Continuously Playing
Pages:
1
[SOLVED]Sound Effect Continuously Playing
CaptainBearFace11
Posts: 15
March 09, 2017, 04:30:48 pm
Hello forum, I am having an issue with a sound effect. It is a short punch sound, and I am simply trying to have it play when one actor punches another. However, instead of playing the sound once, it just loops it and makes a machine gun sound. In the code it is set to play, not loop. So what is the issue, how can I make it just play once on contact?
« Last Edit: March 09, 2017, 07:29:46 pm by CaptainBearFace11 »
LIBERADO
Posts: 2720
March 09, 2017, 04:55:44 pm
Surely you are continuously running the "play" block, so you are continuously playing the sound.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.
CaptainBearFace11
Posts: 15
March 09, 2017, 04:59:33 pm
The play sound code is set to go off as a result of a collision. So what's happening is that as long as the collision is occurring, the sound is playing. How do I remedy this, where should I put the sound code?
decafpanda
Posts: 206
March 09, 2017, 05:37:20 pm
Couple of things could be going on.
1: Is the sound playing in an updating or always event? This will trigger the sound every frame and give that machine gun effect
2: do you have health implemented in your game or do things die in one hit? If you have not implemented a health system yet and the enemies do not die (but collisions are still registered) what is happening is that Stencyl is registering that collision not just once but a bunch of times while the punch is occurring. So the sound is playing a bunch of times.
This is solved by a simple boolean that I could walk you through and might even be the first steps in implementing a health system.
A quick fix would be to make the enemies die on collision with the punch thus the sound will only play once because only one collision will take place
CaptainBearFace11
Posts: 15
March 09, 2017, 05:41:51 pm
The sound is not in an always or updating event, it is in Type and Type collision event. It sounds like the second situation- there is no health system and the enemies do not die in one hit. I would much appreciate a walk through on how to solve this
merrak
Posts: 2738
March 09, 2017, 06:42:41 pm
I built a standard SFX manager behavior to handle this sort of thing. It's simple to put together. Make a custom block "play sound (SFX) once". The code should add the sound to a list and remove it after a short delay (you can also make this delay a second argument). If the sound is in the list, don't play it. Otherwise, play it and add it to the list.
`/\=======/\"-
Website! -
http://www.anorthogonaluniverse.com
Facebook -
http://www.facebook.com/rlwatson
Twitter -
https://twitter.com/merrak
decafpanda
Posts: 206
March 09, 2017, 07:06:53 pm
Hey I am bored tonight and I figured I would make a video to help you with your problem.
Merrak's behavior most certainly will work for you but you might find watching this video to be informative on booleans and other beginner techniques for gamedev.
I am very new to stencyle too so I have had a lot of the same problems you have. This is how I fixed the issue you are having.
https://www.youtube.com/watch?v=KW-nF5_fb8M
CaptainBearFace11
Posts: 15
March 09, 2017, 07:28:30 pm
Thank you to Merrak and Decafpanda for the help. Decafpanda, that was an incredibly helpful tutorial. Makes total sense, problem solved. Thanks a bunch
decafpanda
Posts: 206
March 09, 2017, 08:02:14 pm
No problem, glad to help!
Extintor
Posts: 5
January 10, 2018, 05:24:01 am
Decafpanda, so many thanks. At least!
Pages:
1