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
9
Question by AlejandroBoss · Feb 22, 2017 at 08:28 AM · triggersoundmusicradius

How to have audio only be heard in a certain radius?

Hi, I'm a sophomore in high school learning Unity and I'm kind of a noob. I've made a few games here and there for myself but one thing I don't know how to work to well with is audio. I have an audio source on a game object that is a campfire. The audio that it is playing is the sound of a crackling fire, but when I play the game, I can hear it from far away. That is the only sound in the game as of right now and it plays as if it's background music, which I don't want. I want it to be heard only in a certain radius, say two unity units. I want it to be like real life, where you can hear a sound getting stronger as you get near it. No not neccessarily like a doppler effect, but more like the sound only plays in a sphere or something. I'll be as clear as possible as log as you can help me. Thank you in advance. No, I do not have any scripts attached to the campfire, but I will script if it's needed to acheive what I want. Thank you

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

4 Replies

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

Answer by zzeeshann · Feb 24, 2017 at 01:22 AM

You need to do three things on Audio Source

  1. Spatial Blend from 2D to 3D.

  2. Volume Rolloff from logarithmic to linear.

  3. Set Minimum and Maximum distance.

This video will show how to do this: https://youtu.be/LrchScd806w

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 AlejandroBoss · Feb 24, 2017 at 07:00 PM 0
Share

This worked great. It's up to date with Unity 5.5 and it does exactly what I want it to do. Thank you @zzeshann. you couldn't have done a better job, thanks

avatar image JorgeAmVF · Mar 14, 2018 at 11:24 AM 0
Share

Works great!

avatar image Kaldrin · Mar 18, 2021 at 12:49 PM 0
Share

Thank you !

avatar image
2

Answer by fred_gds · Feb 22, 2017 at 07:01 PM

Well did you take a look at the documentation?

https://docs.unity3d.com/ScriptReference/AudioSource.html

Just set the Audio to 3D and use AudioSource.maxDistance for the effect of the sound getting louder.

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
avatar image
1

Answer by paulbuck86 · Mar 16, 2019 at 05:30 PM

For anyone still having issues, I found that if you do not have an "audio listener" on your player. You will hear all sounds. Make sure you have an audio listener on your player.

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
avatar image
0

Answer by no00ob · Jan 10, 2018 at 07:19 PM

thanks solved my issues, my problem was it was 0.995 so not at 3D and this messed with it xD

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

11 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

Related Questions

Trigger Start of Sound 1 Answer

Making a sound play only once with a Boolean variable in javascript 1 Answer

Door Opens When Not In Trigger And Sound Help 1 Answer

Sound On Collision Not Working 3 Answers

How to know if my speakers are mute? c# android/ios 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