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 MasterXertz · May 19, 2015 at 10:08 AM · javascriptsoundeffects

Footstep Sound Effect

Hi there,

I am fairly new to Unity and I am trying to add a footstep sound effect. I am following along to this video: https://www.youtube.com/watch?v=dexva26wOzg. What I have is the following:

 #pragma strict
 
 var Steps : AudioClip[];
 private var isWalking : boolean = false;
 private var controller : CharacterController;
 
 function Awake()
 {
 controller = GetComponent(CharacterController);
 }
 
 function Update()
 {
 if(controller.velocity.sqrMagnitude > 0.15 )
 {
 isWalking = true;
 }
 else
 {
 isWalking = false;
 }
 }
 
 InvokeRepeating("Walking", 1.0, 0.6);
 
 function Walking()
 {
 if(isWalking)
 {
 AudioSource.PlayClipAtPoint(Steps[Random.Range(0,Steps.length)],gameObject.transform.position);
 }
 }
 

I do have the Audio Source component. Under Foots(script)>Steps, the Size is = 1 and Element 0 is a correct WAV audio file. Any help would be appreciated. Thanks!

Comment
Add comment · Show 4
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 HarshadK · May 19, 2015 at 10:09 AM 0
Share

What exactly is the problem?

avatar image JewelRay · May 19, 2015 at 07:46 PM 0
Share

Are you getting any sound at all? It looks like you are trying to play the sound clip from a random starting position within the clip. $$anonymous$$aybe you should try AudioSource.Play(). Check out the survival shooter tutorial on Unity there is some code in the Player and Enemy health scripts that may be useful.

avatar image MasterXertz · May 19, 2015 at 09:18 PM 0
Share

The problem is I am not getting any sound at all. I tested the script and it works all the way until line 30.

avatar image hu90 · May 19, 2015 at 09:56 PM 0
Share

$$anonymous$$ake sure that your sound is not a 3D sound if that's not what you want. (select the sound in the Project Pane, and check/uncheck "3D sound" in the inspector).

If you have a 3D sound and that's what you want, make sure the listener is close enough.

Also check if you have an Audio Listener (usually on the main camera).

0 Replies

· Add your reply
  • Sort: 

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

Adjusting system audio levels... Please help! 1 Answer

Terrain texture specific step sounds? 1 Answer

Play sound when out of ammo 0 Answers

change detail in game an the sound? 3 Answers

I have problems with coding 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