- Home /
New to Unity and need some help achieving a sonar effect for 2D game
I'm currently working on a 2D top-down dungeon game where the main character is blind (stupid but interesting). However, the character has the ability to see sound so whenever an object makes a loud noise it must become visible in an otherwise all black screen. This is pretty easy to achieve when talking about sprites and objects, I'd assume I could just keep track of when they are playing sound and toggle their visibility. However I want this effect to have impact on some of the area around the model producing the sound, for example: footsteps create a pulsating "water-ripple" effect that reveals part of the map as the sound ripples away from its source. I have a decent understanding of C#, but have just started with game development in Unity. I tried looking into it myself, and got lost in the world of sharers and don't know where to go from there. I guess I'm just looking for some suggestions of resources I can go to that will help me find a solution to this problem. I'm lost on what I should be looking for in order to achieve this effect.
Answer by Strixie13 · Oct 22, 2019 at 04:44 AM
I would stay away from shader programming. That is super specialized stuff that you would want to learn in general, rather than to trying to solve an individual problem. Check out Unity's particle system. It is a much easier way to achieve these kind of effects. For example, you could have a transparent lit ring texture that gets bigger out from the character. Just do a search in YouTube for Unity Particle System and you will find lots of tutorials.
Answer by glennMediaMonks · Oct 22, 2019 at 12:08 PM
You will most likely end up in having to do a shader solution. the best resource I have found to learn is https://www.youtube.com/channel/UCEklP9iLcpExB8vp_fWQseg/videos follow is 101 & 102 videos as a minimum.
Once you feel a bit more comfortable with them, you would end up using a global shader float3 (vector3) which will be a world position (the origin of your sound). Then each object can have a shader which lights up when the distance(soundworldpos, myworldpos) is small enough. this would be the absolute basics of getting something like a sonar to properly visualize.
later you could make it look better by including a _Time.y value to offset the effect overtime.
Thank you for linking the tutorial. I felt like shaders were the best way to go just didn't know where to start.
Answer by NidoAnxari · Oct 22, 2019 at 07:51 AM
If your environment is dark then you can glow the GameObject which makes the sound. If you tell me something more about the environment you are working in then may be I can suggest something.