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
1
Question by Commander Quackers · Dec 07, 2013 at 02:17 AM · audioslowmotionand

Audio affected by Slow Motion?

Hi, I was wondering, since there is a slow-motion mode in my game.. is there a way to have all audio playing at any given time to be slowed down while in slow-mo? It seems that everything except the audio is slowed down, which isn't very "realistic" so I'm hoping there is a solution.

Thanks in advance.

Comment
Add comment
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

1 Reply

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

Answer by Tomer-Barkan · Dec 07, 2013 at 07:00 AM

You can set the speed the audio is played by modifying the pitch value of the AudioSource. Setting it to anything lower than 1 will be slow, higher than one will be fast.

Read more about AudioSource here:

http://docs.unity3d.com/Documentation/Components/class-AudioSource.html

If you want it to match the game speed, you can attach this speed to the audio sources:

 using UnityEngine;

 public class AudioSpeedMatcher : MonoBehaviour {
     public void Update() {
         audio.pitch = Time.timeScale;
     }
 }
Comment
Add comment · Show 3 · 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 Commander Quackers · Dec 07, 2013 at 07:24 AM 0
Share

Thank you for the answer, but I'm getting these two errors:

Assets/AudioSpeed$$anonymous$$atcher.cs(3,31): error CS0103: The name Time' does not exist in the current context Assets/AudioSpeed$$anonymous$$atcher.cs(3,17): error CS0103: The name audio' does not exist in the current context

Not sure what this means, because I'm not very familiar with C#. Do you know how to fix this?

avatar image Tomer-Barkan · Dec 07, 2013 at 07:30 AM 0
Share

Sorry, class has to be a monobehaviour of course to attach to an object...

If it doesn't recognize Time, however, you might have forgotten to import the unity engine namespace:

 using UnityEngine;

Added both to the code in the answer.

avatar image Commander Quackers · Dec 07, 2013 at 07:32 AM 0
Share

Hmm.. I did forget to add that^. As I said I'm not very familiar with C#, lol. Thank you again, I'll accept your answer.

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

17 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

Related Questions

Heres a Script for SloMo hold left shift 3 Answers

Time.timeScale question 1 Answer

Slow motion problem 1 Answer

How to play sound when object stops moving? 1 Answer

how to get smooth slow motion? 4 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