So I’ve been following a tutorial on how to make a circle of blocks in to an audio visualizer. Only problem is the code he used seems to be either out of date or obsolete. I have a series of syntax errors on line 30 saying they expected semicolons, closed parenthesis, and that one of the parentheses is unexpected.
the line tat has the problem is the line stating
“for (int i = 0, i < numberofObjects; i++) {”
code is as follows:
using System.Collections;
using UnityEngine;
public class Spectrum : MonoBehaviour {
// C#
// Instantiates a prefab in a circle
public GameObject prefab;
public int numberOfObjects = 20;
public float radius = 5f;
public GameObject[] cubes;
public float maxTime;
public float currentTime;
void Start() {
for (int i = 0; i < numberOfObjects; i++) {
float angle = i * Mathf.PI * 2 / numberOfObjects;
Vector3 pos = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius;
Instantiate(prefab, pos, Quaternion.identity);
}
cubes = GameObject.FindGameObjectsWithTag ("cubes");
}
// Update is called once per frame
void Update () {
float[] samples = new float[1024]; AudioListener.GetSpectrumData (samples, 0, FFTWindow.Hamming);
for (int i = 0, i < numberofObjects; i++) {
Vector3 previousScale = cubes*.transform.localScale;*
previousScale.y = Mathf.Lerp (previousScale.y, spectrum * 40, Time.deltaTime * 30);
_ cubes*.transform.localScale = previousScale;
}
}
}*_