How to make the audio louder or quieter depending if they are looking at the part or not?

Hey. I’m currently remaking a game called “Nextbot Graveyard”. In the game, they use a radio and they are trying to locate an nextbot under the ground. The radio will play sounds off the nextbot asking for help, while you gotta try to find him by using “directional audio”. This is audio that gets louder or quieter, depending what direction you look at. How would i re-create this effect?

You could see if the point is on screen: Camera | Roblox Creator Documentation. If it is visible, get it’s distance from the center of the screen(mouse.ViewSizeX/2, mouse.ViewSizeY/2) and use that to determine the volume of the audio.

How would i do this? Like, can you give me an example code that i can use?

1 Like

If you look at the documentation I linked, you will find this photo:

It displays how to get the on screen vector. If it is on screen then get the distance from the center of the screen(you can find the position using the previous post) and the new position by using Pythagorean Theorum(a^2 + b^2 = c^2) or use the .Magnitude with the offset(can be calculated by subtracting one coordinate from another)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.