itHyperoX Posted May 29, 2018 Share Posted May 29, 2018 Hi! I'm working on a cinema script, everything fine, but i don't know how to calculate the volume by distance. Anybody can help me please? local cinemax, cinemay, cinemaz = 0, 0, 0 local x, y, z = getElementPosition(localPlayer) local dis = getDistanceBetweenPoints3D(x, y, z, cinemax, cinemay, cinemaz) local volume = dis/2 -- Idk what to use setBrowserVolume(Screen,volume) Link to comment
DNL291 Posted May 29, 2018 Share Posted May 29, 2018 (edited) Try something like this: local maxDist = 500 local cinemax, cinemay, cinemaz = 0, 0, 0 local x, y, z = getElementPosition(localPlayer) local dis = getDistanceBetweenPoints3D(x, y, z, cinemax, cinemay, cinemaz) local volume = ( dis / maxDist ) volume = dis >= maxDist and 1 or volume setBrowserVolume( Screen, 1-volume ) Edited May 29, 2018 by DNL291 1 Link to comment
itHyperoX Posted May 30, 2018 Author Share Posted May 30, 2018 11 hours ago, DNL291 said: Try something like this: local maxDist = 500 local cinemax, cinemay, cinemaz = 0, 0, 0 local x, y, z = getElementPosition(localPlayer) local dis = getDistanceBetweenPoints3D(x, y, z, cinemax, cinemay, cinemaz) local volume = ( dis / maxDist ) volume = dis >= maxDist and 1 or volume setBrowserVolume( Screen, 1-volume ) Thank you! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now