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 /
This question was closed Oct 24, 2018 at 01:26 PM by Nosmo for the following reason:

Other

avatar image
0
Question by Nosmo · Oct 18, 2018 at 05:12 PM · audiosoundaudiosourceaudiocliplooping

What could make the audio loop?

Im playing a sound for health pickups and from the moment they appear the pick up sound starts, the audio source doesn't have "loop" option ticked so what else could it be?

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 Hellium · Oct 18, 2018 at 05:20 PM 0
Share

Please, edit your question, and provide the code you currently have, 99% change you have a problem with your scripts....

avatar image TreyH · Oct 23, 2018 at 03:17 PM 0
Share

Do their AudieSource components have Play On Awake checked?

alt text

play-on-awake.gif (32.9 kB)

2 Replies

  • Sort: 
avatar image
0

Answer by DragonFang17 · Oct 18, 2018 at 05:21 PM

Is it supposed to play before or after the player picks it up?

Comment
Add comment · Show 4 · 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 Nosmo · Oct 23, 2018 at 01:16 PM 0
Share

its supposed to play as the player picks it up.

Think Sonic picking up the rings as an example.

But in my case the rings make the noise from the moment they appear in a loop

avatar image Casiell Nosmo · Oct 23, 2018 at 01:32 PM 0
Share

You should really provide your code, how are we supposed to help without it?

avatar image Nosmo Casiell · Oct 23, 2018 at 02:24 PM 0
Share

I didn't really need help with code, Ive got that. I'm just asking for suggestions as to why the sound would go on a loop. $$anonymous$$y guess is its a setting issue but i dont know what

but if you need it ...

public class HealthupNoise : $$anonymous$$onoBehaviour {

 public AudioSource HealthAudio; //addition

 // Use this for initialization
 void Start () 
 {
     HealthAudio = GetComponent<AudioSource> (); // addition
 }
 
 // Update is called once per frame
 void OnCollisionEnter (Collision col){
     if (col.gameObject.tag == "HealthPickup") {

         HealthAudio.Play ();  // addition

         Debug.Log ("Bing!"); // addition

         //Destroy (col.gameObject);
         //NB: Audio is looping and "loop" option is not ticked 
     }
 }

}

Show more comments
avatar image
0

Answer by Lost_Syndicate · Oct 23, 2018 at 03:17 PM

So, your code is called every frame, So its going to loop and sound hideous. There are 2 ways of solving this.

 public AudioSource audioSource;
 
 private bool ticked;
 private void Start()
 {
 audioSource = GetComponent<AudioSource>();
 // Play it in here
 audioSource.Play();
 }
 
 private void Update()
 {
 // OR, make a bool (as you can see "tick")
 if (!ticked)
 {
 audioSource.Play();
 ticked = true;
 }
 }

As you can see, those are the 2 ways i would prevent it from looping. first one i highly recommend if you want to play it on start, or even just tick play on awake, on the audio source and that should fix it. Other method is just using a bool to act as a toggle. Hope this helped you.

Comment
Add comment · Show 7 · 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 Nosmo · Oct 23, 2018 at 03:55 PM 0
Share

I was ai$$anonymous$$g for on trigger enter function, but ill try your suggestion

thank you

avatar image Nosmo · Oct 23, 2018 at 04:37 PM 0
Share

it's only working when it appears not when i move onto it.

avatar image GamitusLabs Nosmo · Oct 23, 2018 at 04:51 PM 0
Share

based on these two replies, it sounds like it's a health pickup. so use the OnCollision/OnTrigger in conjunction with AudioSource.PlayClipAtPoint. The playclipatpoint will create a one-shot audio source which will prevent the audio from cutting out on the pickup being destroyed, and will destroy itself when the audioclip finishes.

avatar image Nosmo GamitusLabs · Oct 23, 2018 at 05:12 PM 0
Share

well right now ive just got the code down as

public class HealthupNoise : $$anonymous$$onoBehaviour {

 void OnCollisionEnter (Collision col) 
 {
     
     if (col.gameObject.tag == "HealthPickup")
     {
         Debug.Log ("Bing!"); // addition
     }
 }

}

And Bing isn't appearing on the console. The pick is tagged as HealthPickup, the box collider is set to trigger and the script is attached to the pickup so Ive no clue as to why it's not working.

Any suggestions?

Show more comments

Follow this Question

Answers Answers and Comments

127 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 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 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 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 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 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

Is there a way to create a random Audiosource loop? 2 Answers

PlayOneShot returns false for isPlaying 5 Answers

Audio cuts out once a certain number of sounds are played 0 Answers

Play sound from an array, not random, and only once 3 Answers

How to get decibel's value of game's sound? 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