Jump to content
  • Advertisement
Sign in to follow this  
THACO

playing SFX only once

This topic is 4792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using FMOD to play sounds, its great. The one problem I am using scripting to control characters and such which seems to be working well except for this problem. I have it setup so the script can call my C++ function to play a soundfx based on the file name. I currently would play a sound if X amount of time has passed since start of attack/animation. The only problem it will keep adding instances of that sound to play every frame after time X. I can't say just play it when you hit the exact time or an exact frame just incase due to time/machine performance it skips over that one specific time or framee. Any ideas, I can't just check if that sound is currently playing because multiple characters might want to use that sound so I would have to let the sound be played multiple times. Any idea or will I have to use some ugly hacks? -THACO

Share this post


Link to post
Share on other sites
Advertisement
Well, first of all, you shouldn't check if time or frame is equal to something, use greater-than-or-equal because then you don't have to worry about the CPU hitting the time right on the nose.

Second of all, it sounds to me like the problem is in the interface between the script language and your C++ code, or within your sound playback code, in that it should be able to play a sound once, and then once it's done playing it, stop. The audio API you're using should be able to take care of the possibility of alot of stuff going on at once, and doing the mixing and buffer allocation.

Share this post


Link to post
Share on other sites
I think I found a solution to my problem. What I am doing now is just having a variable in the script that starts at zero when a new animation/action is started and each sound gets played when that variable reaches a certain number. It is incremented when a certain frame/time has been passed over. It isn't perfect but shouldn't cause to many problem

-THACO

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!