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
3
Question by hankphone · May 04, 2010 at 03:36 PM · audiodistort

Distorted audio clips. Help please.

I have a class project do in less than 24 hours and all of my sound effects are playing distorted. Any audio I use for bg music is fine though. For example, a door sound is played when opening a door but it is stretched out and computerized sounding. I have tried wav, mp3, ogg, various compression settings, 3d/not 3d, for mono, native format/compressed format. I have no idea what's going on. Here is a script I am using to open a door and it calls the sound, idk if it's the script?

var sound: AudioClip; var Scene : String; static var inTrigger = 0;

function OnTriggerEnter(other : Collider) { if(other.name == "Player") { inTrigger = 1; }
}

function OnTriggerStay (other : Collider) { if(other.name == "Player") { inTrigger = 1; }

    //turns on motor to open the door when player hit fire2 and is near door
if(Input.GetButton("Fire2") && other.name == "Player")
{
    this.hingeJoint.useMotor = true;
    audio.PlayOneShot(sound);
    yield WaitForSeconds (2);
    LoadNewLevel();
}

}

function LoadNewLevel () { //if (Application.CanStreamedLevelBeLoaded ("Basement") && ) //{ inTrigger = 0; Application.LoadLevel (Scene);

// } }

function OnTriggerExit(other:Collider) {

inTrigger = 0;

}

function OnGUI () { if(inTrigger) { // Make a background box GUI.Box (Rect (Screen.width / 2 ,Screen.height / 2,150,50), "Press E to open door"); }

Comment
Add comment · Show 5
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 Molix · May 04, 2010 at 04:33 PM 0
Share

Does it sound ok in the preview pane? (i.e. select the sound in the Project pane, then in the Inspector at the bottom there is a Preview pane with a little Play button)

avatar image spinaljack · May 04, 2010 at 05:05 PM 0
Share

Could be to do with the audio listener, is there more than one? Are you standing far away?

avatar image hankphone · May 09, 2010 at 07:25 PM 0
Share

Yeah, it sounds just fine in the preview pane.

I don't think there is more than one listener in the scene but I'll go double check. The sounds play when a door opens or the player picks up an item so the player is generally very close to the audio source.

avatar image ZeNooB · May 10, 2010 at 04:27 AM 0
Share

I have the exact same problem right now, how do u fix it?

avatar image hankphone · May 10, 2010 at 07:03 AM 0
Share

no idea. All the other sounds play just fine, like bg music. It's just when my scripts call a sound to play for a particular action that they are completely distorted...

2 Replies

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

Answer by jonas-echterhoff · May 11, 2010 at 08:01 PM

From what it looks to me, as you are using Input.GetButton(), you will start playing the sounds every frame, as long as the button is hold down - so, you really have many instances of the sound playing at the same time. Try using Input.GetButtonDown() instead, which will only be "true" once, when the button is first pressed.

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 hankphone · May 11, 2010 at 09:23 PM 0
Share

Yup, that did the trick! Thanks for the answer Jonas, this was driving me crazy as I am not a programmer at heart.

avatar image
0

Answer by Jayland · Dec 17, 2011 at 02:07 AM

What if I wrote a script sayin "If the player is a certain dist of the enemy, play audio.PlayOneShot(sound);" I have the same problem. How do I fix this?

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

1 Person is following this question.

avatar image

Related Questions

Audio trigger by key press - problems 1 Answer

how to play audio at a given time. 2 Answers

Play music troughout whole game in js 1 Answer

Screenshot Movie with Audio Capture 1 Answer

Can Animation detect when Audio Completes 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