Answer the question
In order to leave comments, you need to log in
How to paint over the area under the line?
So, we have a line with 64 points. Each point moves at a certain moment and it is necessary to fill the area under the line, in theory, spriteShape works approximately the same way. It can be done through spriteShape, but I still haven’t figured it out, the line movement code is very simple. I would be grateful for any help!
public float range = 5000f;
public int number = 64;
public float[] znachenia;
public LineRenderer line;
public int spec;
[Range(0, 1)]
public float speedAnimation;
private void Awake()
{
for(int i = 0;i < number; i++)
{
Vector3 posInArray = new Vector3(0,0,0);
if(i>0)
posInArray = line.GetPosition(i-1);
line.SetPosition(i,posInArray+new Vector3(0.2f,0,0));
}
}
void Update () {
float[] spectrum = new float[spec];
GetComponent<AudioSource>().GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris);
for(int i = 0;i < number; i++)
{
line.SetPosition(i,Vector3.Lerp(line.GetPosition(i),new Vector3(line.GetPosition(i).x,(range * spectrum[i] + znachenia[i])/2),speedAnimation));
znachenia[i] = range * spectrum[i];
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question