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 inglipX · Mar 27, 2013 at 07:25 PM · audionotplaying

Audio is not playing but i don't have any compiler errors?

Will not play, although the audio source does show the clip as being played, i don't hear it.

 #pragma strict
 
 
 
 
 
 var concreteSound1 : AudioClip [];
 
 var MetalSound1 : AudioClip [];
 
 private var isWalking : boolean = true;
 
 var footstepTime : float = 0.2;
 
 private var isMoving : boolean = false;
 
 private var isJumping : boolean = false;
 
 private var isOnConcrete : boolean = false;
 
 var clipType : String = "";
 
  
 
 function Update() {
 
     if (Input.GetAxis("Horizontal")) {
 
         isMoving = true;
 
         } else if (Input.GetAxis("Vertical")) {
 
         isMoving = true;
 
         } else if (Input.GetButtonDown("Jump")) {
 
             isMoving = true;
 
             isJumping = true;
 
         } else if (!Input.GetButton("Jump")) {
 
             isMoving = false;
 
             isJumping = false;
             
           
 
         } 
 
         //In order for jump to work, there must be a delay in the time from jump button press to actual jump in order for it to register. Also, ensure GetButtonDown on the player jump script, otherwise, it wont work right.
 
         else if (!Input.GetAxis("Horizontal")) {
 
         isMoving = false;
 
      } else if (!Input.GetAxis("Vertical")) {
 
         isMoving = false;
 
      }
 
 }
 
  
 
 function OnControllerColliderHit (hit : ControllerColliderHit) {
 
     if (hit.gameObject.tag == "Concrete" && isWalking && isMoving || isJumping && isWalking && isOnConcrete) {
 
         Debug.Log ("Walking On Concrete");
 
         isOnConcrete = true;
 
         WalkOnConcrete();
 
     } else if (hit.gameObject.tag == "Metal" && isWalking && isMoving || isJumping && isWalking) {
 
         Debug.Log ("Walking On Metal");
 
         isOnConcrete = false;
 
         WalkOnMetal();
 
     }
 
 }
 
  
 
 function WalkOnConcrete() {
 
     var concreteToPlay : GameObject = GameObject.FindWithTag ("Concrete");
 
     isWalking = false;
 
     yield WaitForSeconds (footstepTime);
 
     audio.clip = concreteSound1 [ Random.Range(0, concreteSound1.Length) ];
 
     clipType = "concreteSound1";
   
     isWalking = true;
 
 }   
 
  
 
 function WalkOnMetal() {
 
         var MetalToPlay : GameObject = GameObject.FindWithTag ("Metal");
 
     isWalking = false;
 
     yield WaitForSeconds (footstepTime);
 
     audio.clip = MetalSound1 [ Random.Range(0, MetalSound1.Length) ];
 
     clipType = "MetalSound1";
    
     isWalking = true;
 
 }
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 iwaldrop · Mar 27, 2013 at 07:36 PM 0
Share

Where do you call audio.Play()?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JChilton · Mar 27, 2013 at 07:29 PM

For most purposes, it's actually best to use 2D sound instead of 3D sound.

Check the import settings on your audioclip, and make sure that '3D sound' is unchecked.

Assuming you left settings default, the 3D sounds don't have a big enough range to reach the audiolistener that is sitting on the Main Camera.

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

12 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

Related Questions

Audio says it is playing in audiosource but is not... 2 Answers

OneShot Audio not playing 1 Answer

A node in a childnode? 1 Answer

Get an object to play a sound if player rolls over a trigger. 2 Answers

Audio plays when i click F 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