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
0
Question by l4iitthh33 · Dec 10, 2018 at 03:42 AM · animationaudio

audio keeps playing after animation is done

so i have events on my walking and running animation so whenever i hit the ground the sound plays but after i stop walking or running it keeps going , its not on loop to also i tried play one shot , here is my script

 public void Step()
 {

     audiosource.Play();

 }

 public void Steprun()
 {

     audiosource.Play();

 }
Comment
Add comment · Show 2
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 hexagonius · Dec 10, 2018 at 08:10 PM 0
Share

I can't see any Stop.

avatar image nicholasw1816 · Dec 12, 2018 at 11:52 PM 0
Share

$$anonymous$$ake sure you don't have loop checked in AudioSource my friend.

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Ghazi360 · Dec 10, 2018 at 08:21 PM

Add audioSource.Stop();

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 l4iitthh33 · Dec 12, 2018 at 10:08 PM 0
Share

its not working it plays and stop immediately i tried before

maybe i placed it somewhere wrong where do i add it ?

avatar image
0

Answer by Browntown90 · Dec 12, 2018 at 10:35 PM

The audio is going to continue playing until you stop it. Like @Ghazi360 said, you'd have to add audioSource.Stop();

Since you pointed out that's causing it to stop immediately I'm assuming you've tried something like

 public void Step()
 {
     audioSource.Play();
     audioSource.Stop();
 }

Which would cause the audio to play and immediately stop. If you want audio to play until you've stopped running, try this, and call Idle() when the animation is set to stop.

 public void Step()
 {
     audioSource.Play();
 }
 public void Idle()
 {
     audioSource.Stop();
 }

.

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 l4iitthh33 · Dec 12, 2018 at 11:12 PM 0
Share

so the idle thing do i have to add it somewhere on the editor or something or thats it ?

avatar image
0

Answer by Ketoleperouch · Dec 12, 2018 at 10:44 PM

I'm assuming you mean it keeps executing the events that play the sound? If you mean you want to stop the sound, check the other answers.
Are you firing the events within a Blend Tree? Blend Trees execute events even when the 'evented' animation plays for 0.01%, if you know what I mean (so even if e.g. your MoveSpeed parameter inside the Animator is 0.00001, so it plays your Moving animation - with the event - for 0.00001% or so).
You'll want to add a separate boolean that keeps track of whether the sounds should play and edit your script so it behaves correctly, for example:

public void Step() { if (myAnimator.GetBool("Moving")) { audiosource.Play(); } }
etc.
Alternatively, you could use the animator move speed parameter as a variable for the volume of the AudioSource, so the move sound plays at a low volume when you walk slowly, for example:
public void Step() { audiosource.volume = Mathf.Clamp01(myAnimator.GetFloat("MoveSpeed")); audiosource.Play(); }
I hope this is useful to you!

Comment
Add comment · Show 2 · 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 l4iitthh33 · Dec 12, 2018 at 11:20 PM 0
Share

ty so much for your help but am kidna confused am new i dont really know about this but ty for helping , so are both of them different cuz the first one seems easier also if i want to add a new bool what do i do ? i mean how do i reference "$$anonymous$$oving"

avatar image Ketoleperouch l4iitthh33 · Jan 09, 2019 at 10:11 PM 0
Share

Yeah so first of all, are you using events inside the Animation Tracks? If not, then my answers won't help. Both methods are indeed different and to add a new bool you can refer to, you'll have to add one inside the Animator tab inside the Animator window.

avatar image
0

Answer by nicholasw1816 · Dec 12, 2018 at 11:53 PM

Make sure the loop is unchecked in the AudioSource Component, in the inspector.

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 l4iitthh33 · Dec 13, 2018 at 12:35 AM 0
Share

yeah its unchecked

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

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

Play from a variety of sounds? 1 Answer

Can I make animations snap to a frame? 1 Answer

stop triggers from retriggering animation 2 Answers

GameObject reacts to audio source 1 Answer

Synchronize Audio and Animation 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