Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Anoj · Feb 24, 2010 at 11:00 AM · collisiontriggersound

How to get sound to play on barrel Explosion

can someone help me out with this plz. right now i got the barrel to explode but i cant seem to get my sound to play when the barrel explodes.

Comment
Add comment
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

1 Reply

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

Answer by duck · Feb 24, 2010 at 11:28 AM

You might want to use PlayClipAtPoint for this. It's great for one-off sound effects which can occur at an arbitrary position in your scene.

How you do this might depend on how you're detonating the barrel. If you have some function on your barrel which handles the explosion, you might do:

var explosionClip : AudioClip;

function Explode() { AudioSource.PlayClipAtPoint(explosionClip , transform.position);

// (then whatever code generates the explosion) Destroy(gameObject); }

You'd then need to make sure you drag in a reference to the audio clip, into the "explosionClip" variable in your barrel object (or prefab).

Comment
Add comment · Show 2 · 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
avatar image Anoj · Feb 24, 2010 at 04:00 PM 0
Share

Hi thanks for getting back to me... theres a small issue here. I'm using the script from FPS tutorials "DamageReceiver.js" using that script i got the barrel to employed but after updating it with your scrip its still not playing the sound. I'm i doing something wrong.

avatar image duck ♦♦ · Feb 25, 2010 at 10:42 AM 0
Share

Are you getting any errors when the sound is supposed to play? Did you put the line "AudioSource.Play...etc" into a function that is actually called, or did you just add the whole Explode() function? Did you drag the explosion sound audio clip into that variable in the inspector?

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

No one has followed this question yet.

Related Questions

Alternate between two Audio clips on collision 3 Answers

Sound plays even though on awake is unticked 1 Answer

Trigger with Gravity + Collision 2 Answers

How to add to a 3D object's length through code? 1 Answer

How to make my animated axe collide with tree properly?? 0 Answers


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