Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by Lukalotr · Jun 08, 2018 at 09:18 PM · audiobugsound

All sounds instantly play on game start.

When I start my game, all the sounds play instantly once. They play like normal after that, but the random outburst really ruins the feel. I'm looking for a way to fix this, but I can't find any solution anywhere else. Here's my current script that plays audio... the script is applied to an object with AudioSystem for each individual sound, and then the AudioSystem objects are in turn applied to scripts that need to play them.

public class AudioScript : MonoBehaviour { public AudioClip MusicClip; public AudioSource MusicSource; // Use this for initialization void Start () { MusicSource.clip = MusicClip; MusicSource.Play(); } // Update is called once per frame void Update () { } }

Any help? I am new to Unity, and all my prior programming experience is in JS.

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

2 Replies

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

Answer by Sgt_Spike · Jun 09, 2018 at 04:50 PM

Are you sure you don't have the 'Play on Awake' option on in the Unity Editor for your audio sources? Having this option on will make that audio source play as soon as the object it is attached to becomes active.

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 Lukalotr · Jun 17, 2018 at 05:37 PM 0
Share

Yes, I'm certain that none of my sounds other than my soundtrack have playOnWake set to true. Heres one of my audioObjects... https://imgur.com/a/7aUHD0i

Also, sorry for late reply, thanks for helping...

avatar image Sgt_Spike Lukalotr · Jun 17, 2018 at 08:51 PM 1
Share

So you say these audioObjects are called from individual scripts when they are needed. Are the audioObjects (like the one you provided) always in your hierarchy or do they get added to the hierarchy during play mode from another script. If they are always in your hierarchy, there's your problem. You are playing the audio source in your Start() method, meaning as soon as that script becomes active, it is immediatly going to play the sound.

avatar image Lukalotr Sgt_Spike · Jun 17, 2018 at 08:53 PM 0
Share

Ohh, that must be the problem then, thanks! How do you suggest I fix it most easily?

Show more comments
avatar image
0

Answer by JulesVerny · Aug 23, 2021 at 03:15 PM

@Lukalotr I had a similar problem. Really frustrating as to why a particular Audio file was playing on startup, as it was no different to any of the other audio files.

I diagnosed it down to being that the name of this Audio File was the same as a GameObject, or named asset. So that Unity seems to get confused and played that Audio, because of its name clashed with a corresponding named assets. (They played correctly by script in the main game.

Once I renamed my Audio File(s) to be distinct, they did not play on Startup. So its now sorted.

Comment
Add comment · Show 1 · 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 Buchi0 · Apr 21 at 03:10 PM 0
Share

This did help. I had the same problem (one file playing at start for no obvious reason) Renaming within unity did not help. I had do rename that file on the disk (to some unknown ending) and delete the .meta file. Then unity showed it up as white box, and it did not play. Changing its name back to a playable file format made it show up in unity again, and it is perfectly usable at all, but does not play at start,

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

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

Cracking at end of audio? 0 Answers

Stopping the car audio when im not in the car 1 Answer

Need help: new sound isnt played correctly anymore 2 Answers

No sound after recieving a phone call - Android 1 Answer

How should I prep audio assets for looping so as to avoid pops clicks etc. 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