I have a few parameters from a different class AnalogGlitch, which I want to assign within this code. Instead of assigning values to them individually, I want to pack them in a list and to this in a loop.
However from the output I can see that the values of the variables to not change at all. I have not used as much C# before and wonder if this is something specific to the language (and not in python for example)?
The code works finde, when I assign values to the variables individually instead of in a loop ...
public class SlenderInView : MonoBehaviour
{
private AnalogGlitch glitch;
private bool isLooking = false;
private List<float> controls = new List<float>();
void Start()
{
glitch = GetComponent<AnalogGlitch>();
controls.Add(glitch.scanLineJitter);
controls.Add(glitch.horizontalShake);
controls.Add(glitch.colorDrift);
}
void Update()
{
// removed the code dealing with isLooking
if (isLooking)
{
for(int i=0; i<controls.Count; i++)
{
if(controls[i] < 1)
{
controls[i] += (float)0.1;
}
}
}
else
{
for (int i = 0; i < controls.Count; i++)
{
controls[i] += 0;
}
}
}
}