Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 crocodile5 · Apr 20, 2012 at 01:52 AM · gameobjectaudioaudiosource

audiosources not playing after object destruction

I have enemy spaceships in my game using the same script for their AI and that particular script also holds the sound effects played from those objects. I am using this technique in my previous question for the sounds. But I have a certain problem.

When the first spaceship gets destroyed in the scene the explosion sound stops playing when other spaceships explode. It gives "Can not play a disabled audio source" warning in the editor. But the wierd thing ONLY explosion sound stop playing other sounds play just fine like engine sound, weapon sound etc. Is there any way to reload the sound or something so the explosion sound plays fine for the rest of the spaceships that are alive?

Comment
Add comment · Show 4
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 syclamoth · Apr 20, 2012 at 02:26 AM 0
Share

Is the explosion sound attached to the spaceship itself? I would have thought that sound persisting after an object is destroyed would be a bigger bug! Try making the explosion sound separate from the rest of the system- similarly to how you would create an explosion particle effect that exists momentarily after the spaceship is destroyed.

avatar image crocodile5 · Apr 20, 2012 at 12:35 PM 0
Share

I will explain in detail how this happens.

I have 5 npc spaceships in my scene. I have a NPCAI script that is attached to these objects. Also this script has the audioclips and audiosources for the npc spaceships. Since all npc spaceships use the same sounds I have the same sounds attached to every spaceship object via the NPCAI script.

Now,problem is this. When a NPC spaceship dies it plays the explosion sound just fine. But after that when another npc spaceship dies I get the warning "Can not play a disabled audio source" and I hear no sound. But this happens only for the explosion sound. NPC engine sounds, weapon sounds etc just plays fine without any warnings even after the first spaceship gets destroyed.

I can probably add a seperate child gameobject to the npc spaceships and play the explosion sound that way but I can see the other sounds play just fine so I dont understand why this happens to the explosion sound.

avatar image aldonaletto · Apr 20, 2012 at 12:59 PM 0
Share

Could the explosion AudioSource reference be a static variable? Static variables are unique: if this reference is static, each new ship created will overwrite it, thus all ships end referencing the same AudioSource.

avatar image crocodile5 · Apr 20, 2012 at 01:45 PM 0
Share

I will try that.

$$anonymous$$eanwhile I added an audiosource to the explosion itself so everytime the particle effect instantiates explosion sound plays fine that way. But now it has other problems, as multiple sounds dont play together sometimes but for now I solved the main issue :).

Thanks for the help.

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Volume Control with Slider 1 Answer

Can I play multiple AudioSources from one gameobject? 8 Answers

How to play sound while animation load using assetbundle 0 Answers

How to control backsound on/off in the third scene 1 Answer

Play Sound On Object In Another Scene With Button from First Scene 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges