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 /
This question was closed Mar 06, 2015 at 04:38 PM by Razputin for the following reason:

I fixed it myself.

avatar image
0
Question by Razputin · Feb 11, 2015 at 01:01 AM · audioplayerprefsontriggerenteraudioclipplayoneshot

Audio not playing on TriggerEnter (Pic Included)

Hi, i'm trying to make it so when my player character enters a gems trigger it plays a sound, destroys the gem, then sets the playerpref to 1. But I can't get the sound to play?

Can someone take a look at this and tell me why the sound might not be playing.

alt text

halpplz.png (143.6 kB)
Comment
Add comment · Show 1
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 Razputin · Feb 11, 2015 at 03:25 PM 0
Share

Bumping post

3 Replies

  • Sort: 
avatar image
0

Answer by Stardog · Feb 11, 2015 at 01:06 AM

Try adding a Rigidbody2D (isKinematic set to true) to the Gem.

Comment
Add comment · Show 6 · 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 Razputin · Feb 11, 2015 at 01:09 AM 0
Share

Still not workin

avatar image Stardog · Feb 11, 2015 at 03:33 AM 0
Share

Is your Box Collider set to be a trigger?

avatar image Razputin · Feb 11, 2015 at 01:36 PM 0
Share

yes. It does get destory and the playerpref is set to 1. It just doesn't play the sound.

avatar image chariot · Feb 11, 2015 at 03:29 PM 1
Share

cause you destroys object before playing full sound? :)

avatar image Razputin · Feb 11, 2015 at 03:32 PM 0
Share

Probably. I'll move the sound from the gem to the player.

Show more comments
avatar image
0

Answer by t-schulz · Mar 02, 2015 at 12:03 PM

if you play a sound and delete the object, the sound will NOT be played. Delay the Destroy() and the sound will play!

Thanks to chariot for the hint!

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
avatar image
0

Answer by Digital-Phantom · Mar 02, 2015 at 12:54 PM

Use a coroutine for your sound. In some cases on trigger enter only actually has an effect for that brief moment the trigger is entered.

You could try using OnTriggerStay instead (depending on your needs)

Personally I would just add something like -

start coroutine PlayTheSound() (add this line to your OntriggerEnter event)

Then make another function -

 void PlayTheSound()
 {
    //**insert your sounds line of code here**
 }
 

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

Follow this Question

Answers Answers and Comments

22 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 avatar image avatar image

Related Questions

Sound wont play when triggered (javascript) 1 Answer

PlayOneShot in OnTriggerEnter function (Unity 5) 0 Answers

My soundclip is noisy? 2 Answers

How to fix my reload sound? 0 Answers

Need help with AudioSources 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