• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Souk21 · Feb 08, 2015 at 01:16 PM · audioaudiosourceaudioclip

Multiple PlayOneShot bug

Hi! I have this script attached to my main camera:

 public class soundCamera : MonoBehaviour {
     public AudioClip shot;
     public AudioSource source;
 
     public static void shotSound() {
         source.PlayOneShot (shot);
         }
     }

When I need the "shot" sound to play, I can call shotSound() from another script:

 soundCamera.shotSound()

It works great until I try to play a lot of sound in a row. Then it just stops playing the AudioClips. If I wait several seconds, it works again.

I want a lot of sound feedback in my game, so I'll have to fix this issue.

Thanks in advance!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Truger · Feb 08, 2015 at 01:33 PM 1
Share

I've noticed this has happened to me before when the audio file i was using was '.mp3' after converting them to an uncompressed format like '.wav' my issues went away.

$$anonymous$$aybe the audio buffer is getting full, errors out and just cancels the action?

avatar image Souk21 · Feb 08, 2015 at 02:10 PM 0
Share

$$anonymous$$y sounds are in mp3, I'm gonna try with wav, thanks :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Souk21 · Mar 23, 2015 at 08:28 AM

I çhanged the compression to uncompressed, and it now works :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

2.1ch, 4.1ch, 6.1ch 音源の再生方法について ( About how to play 2.1ch, 4.1ch, 6.1ch sound source) 0 Answers

audio.clip.GetData() returns no data. 0 Answers

Unity 5 low audio volume 1 Answer

Playing many audioclips with PlayOneShot causes all sound to cut out. 0 Answers

Why does AudioSource cut off beginning of manually looped clip in certain conditions? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges