How to lerp PlaybackLoudness?
I wanted to learn how to make stuff react to audio. I did some research the property I needed to loop into was PlaybackLoudness. I tested out this feature while changing the range of a PointLight on a part and it worked! Here is the code:
2 | workspace.SoundPart.PointLight.Range = script.Parent.PlaybackLoudness/ 25 |
The problem with the script above is it updates REALLY REALLY quicky and the light flashes a ton! So I tried lerping.
To implement a lerp, I made this code below:
04 | return a * ( 1 -t) + (b*t) |
07 | local prePlaybackLoud = 0 |
08 | local postPlaybackLoud = 0 |
12 | prePlaybackLoud = script.Parent.PlaybackLoudness |
14 | postPlaybackLoud = script.Parent.PlaybackLoudness |
21 | local ppL = prePlaybackLoud |
22 | local pPL = postPlaybackLoud |
25 | workspace.SoundPart.PointLight.Range = lerp(prePlaybackLoud/ 25 , postPlaybackLoud/ 25 , i) |
It seems to update 2 seconds late and it runs the lerp on the second before in the song. This was my final attempt before writing this question.
GOAL: I want to learn how to smoothly visualize audio on the range of a point light.