• 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 scipiothegreat · Jul 03, 2013 at 04:27 AM · physicssoundsimulation

Speed of sound delay

Is there a way to simulate speed of sound delays? Like if there is an explosion a mile away, is there a way I can make it so that the sound happens slightly after you see the explosion? Or would it just have to be something I simulate with a script that measures the distance between the listener and source?

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 sasakovacevic · Mar 30, 2016 at 12:11 PM 0
Share

I think they should incorporate speed of sound in some future releases. It's really bad to hear explosion instantly.

Show more comments

2 Replies

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

Answer by TonyLi · Jul 03, 2013 at 01:10 PM

Just make it a 3D sound:

If the Sources are 3D (see import settings in Audio Clip), the Listener will emulate position, velocity and orientation of the sound in the 3D world (You can tweak attenuation and 3D/2D behavior in great detail in Audio Source)

(From the Sound page.)

If you need to handle it differently, start a coroutine that delays the appropriate amount of time.

First you need a function that computes the sound delay between two objects. Something like (see Speed of Sound):

 float SoundDelay(Transform a, Transform b) {
     float speed = 331.4f + 0.6f * temperatureCelsius;
     return Vector3.Distance(a, b) / speed;
 }

If you only have one listener (e.g., the player), you could do this:

 void IEnumerator Explode(Transform listener) {
     animation.Play("Explosion");
     float soundDelay
     yield return new WaitForSeconds(soundDelay);
     audio.Play();
 }

If you need to broadcast it to multiple listeners, you can use BroadcastMessage(). to tell every component to delay a certain time and then play the explosion sound.

Or, if you want to get overly complicated, you could create a collider that expands over time. Every listener can handle the collision with the "sound wave" collider using OnColliderEnter().

Comment
Add comment · Show 6 · 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 Eric5h5 · Jul 03, 2013 at 03:08 PM 0
Share

A 3D sound doesn't emulate the speed of sound at all.

avatar image TonyLi · Jul 03, 2013 at 04:53 PM 0
Share

Okay, then @scipiothegreat go with my other suggestions. :-)

avatar image scipiothegreat · Jul 03, 2013 at 06:53 PM 0
Share

Thanks, I was just wondering if there was a built in way to do it.

avatar image meat5000 ♦ · Sep 18, 2013 at 01:13 PM 0
Share

@Eric5h5 There is a Speed of Sound entry in audio manager. Are you suggesting this does nothing or are you suggesting it applies to anything, not just 3D sound?

avatar image Bunny83 · Sep 18, 2013 at 02:56 PM 1
Share

This is probably used for the doppler effect, but audio is played immediately, no matter how far it is away.

Show more comments
avatar image
0

Answer by Eric5h5 · Jul 03, 2013 at 05:14 AM

would it just have to be something I simulate with a script that measures the distance between the listener and source?

Yes.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Simulating the graphics of a rolling 3D ball in a 2D game 2 Answers

What would be the best approach to implement a conveyor belt? 0 Answers

Help with orbits 1 Answer

cloth simualtion problem 0 Answers

simulating real world camera in unity 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