Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by Sylux102 · May 08, 2016 at 12:44 AM · soundaudiolistenersplineradar

Audio Based Radar System Help?

I'm looking for a way to create a radar system similar to what's found in Metal Gear Solid Peace Walker. An inner circle shows the volume of the players sounds, which is visualized by an inner ring distorting the amount of volume the player produces. An outer circle shows the direction and volume of everything else.

How would such a radar system be achieved? I can imagine that it'd use line renderers or splines to create the circles, which would be split into points which would then be individually distorted according to volume. However, I'm getting hung up on the outer circle. How can I detect the direction from the audio listener on the player, and then apply that volume variance and direction to the radar in the correct orientation?

I guess for performance I could fake the actual waveforms and simply use some RNG for the distortion amount multiplied by the volumes. However, actually achieving the radar would be an important first step.

Thanks Sylux102

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 Oribow · May 08, 2016 at 12:58 AM 0
Share

S$$anonymous$$lth games normaly simulate noise and hearing for the AI. They just look at what the character is doing, assign a "volume", that deter$$anonymous$$ds how far it's hearable and then message every listener in the surrounding about that noise and what caused it (AIs shouldnt have to guess based on what sinus wave they are getting). What you want is beyond Unitys default audiolistener and you would have to implement your own "awarness system". That does not mean, that you replace Unitys audio components, rather that use your system for deter$$anonymous$$ding what the AI hears and Unitys audio components to let the player hear your gamesounds.

avatar image Sylux102 Oribow · May 08, 2016 at 01:42 AM 0
Share

Im not so much having an issue with what AIs are hearing. I'm looking for taking "surround output data" if you will from the audio listener component to apply it to a HUD element for the players radar. I've already achieved the inner circle, using the following hacked up code from a Reddit user.

 AudioSource audioSource;
 public LineRenderer waveform;
 public float waveformHeight    = 5f;
 public float waveformRadius    = 20f;
 const float TWOPI = 6.283185f;
 const int WAVEFOR$$anonymous$$_SA$$anonymous$$PLES = 1024;
 const int FFT_SA$$anonymous$$PLES = 4096;
 float[] fft = new float[FFT_SA$$anonymous$$PLES],
             fft_history = new float[FFT_SA$$anonymous$$PLES],
             data = new float[WAVEFOR$$anonymous$$_SA$$anonymous$$PLES],
             data_history = new float[WAVEFOR$$anonymous$$_SA$$anonymous$$PLES];
 void Start()
 {
      waveform.SetVertexCount(WAVEFOR$$anonymous$$_SA$$anonymous$$PLES);
 }
 void Update()
 {
 audioSource.GetSpectrumData(fft, 0, FFTWindow.BlackmanHarris);
 audioSource.GetOutputData(data, 0);
 Vector3 vec = Vector3.zero;
 for(int i = 0; i < WAVEFOR$$anonymous$$_SA$$anonymous$$PLES; i++)
 {
     int n = i < WAVEFOR$$anonymous$$_SA$$anonymous$$PLES-1 ? i : 0;
                 vec.x = $$anonymous$$athf.Cos((float)n/WAVEFOR$$anonymous$$_SA$$anonymous$$PLES * TWOPI) * (waveformRadius + (((data[n] + data_history[n]) * .5f) * waveformHeight));
                 vec.z = $$anonymous$$athf.Sin((float)n/WAVEFOR$$anonymous$$_SA$$anonymous$$PLES * TWOPI) * (waveformRadius + (((data[n] + data_history[n]) * .5f) * waveformHeight));
 
                 vec.y = 0f;
 
                 waveform.SetPosition(i, vec);
             }
 

I'm just having issues applying directional audio data using this method. The above cs is attached to a gameobj with a linerenderer component and audio source to test. Works exactly as I want. Just can't figure out directional audio for this.

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

55 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

Related Questions

What causes the audio clicking & how do I get a clean sound? 11 Answers

How can I turn off the sound from another scene? 0 Answers

how to make sound settings button? 1 Answer

Sound doesn't always play 0 Answers

adding instruments to the music Wwise 1 Answer


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