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 evitabear · Mar 08, 2012 at 08:34 AM · soundcar

Car Tutorial #1 - Sound Broken

Hi, I'm a beginner making my way through my first tutorial. I'm a Mechanical Engineer with experience in Matlab, VB.net (mainly visual basic, but some C), and a number of proprietary scripting languages. So far Unity looks a lot like the vb.net framework, so that's nice.

I have just completed part 1 of the car tutorial and most everything seems to work - there are skid marks, lighting seems on, etc. The problem is some of the sounds don't work. I double/triple checked all the settings and also checked the files to make sure that they are running. The only odd think I noticed is that some of the sound files were mistyped with "can" instead of car, but that should affect anything. I even tried a "build ad run" to make sure it wasn't a problem with the editor mode, but the sound also has trouble there. The sounds that do work include the crash and initial door slam. The theme song and engine sounds do not work.

There are no console errors.

I tried putting in a Debug.log check inside of the functions for the engine and theme song and both logs show up (theme song just shows up at initialization of game and engine log repeats.

Any ideas? Thanks for helping out a newbie! =)

alt text

alt text

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 evitabear · Mar 08, 2012 at 08:16 AM 0
Share

Actually I figured this out with the help of http://forum.unity3d.com/threads/126188-Sound-problem-with-Car-Tutorial-in-Unity-3.5?p=850067

The problem is that the .playOnAwake = true statements are being executed inside the Awake() function, which makes little sense. In order to get it to work, just remove the .playOnAwake = true statements, and add simple .Play() calls once the settings are configured - i.e. the last statement for that audio object. For example:

function Awake() { car = transform.GetComponent(Car);

 DVolume *= 0.4;
 EVolume *= 0.4;
 FVolume *= 0.4;
 $$anonymous$$Volume *= 0.7;
 LVolume *= 0.4;
 windVolume *= 0.4;
 
 DAudio = gameObject.AddComponent(AudioSource);
 DAudio.loop = true;
 //DAudio.playOnAwake = true;
 DAudio.clip = D;
 DAudio.volume = DVolume;
 DAudio.Play();

If you have something more complex going on, you may want to check if the audio is already playing:

if (!DAudio.isPlaying()) { DAudio.Play(); }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Meltdown · Mar 08, 2012 at 08:36 AM

This is an issue since 3.5 was released. In fact Unity has decided that this is going to be expected behaviour from now on.

Simply do the following check..

 if(!DAudio.isPlaying)
   DAudio.Play();
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

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

Unity5 Vehicles package sound problem 0 Answers

Car audio script 0 Answers

How to i make a gear system from this script? help please 1 Answer

audio fades 0 Answers

Buggy Engine Sound (pitch) 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