Hi!
I got a few floats and I want to be able to check when 1 of them has set a value to it.
Like when x1 = 20f; I want to be able to check it. And if so, how to remove that value. I’m not sure how to do this. I thought an array or something but I’m not sure how to check if one has a value.
The floats: v
private float x1;
private float x2;
private float y1;
private float z1;
private float z2;
private float z3;
private float floatArray = new float[6] {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}; // Define a new float array and give it the name ‘floatArray’, fill it with some values.
public float x1;
x1 = floatArray[0]; // Assign the value in the first index of our floatArray to the variable x1;
// x1 will now equal 1.0f
Alternatively instead of assigning values to the Array in its definition, you can assign values to its indices 1 at a time like so.
private float[] floatArray = new float[6]; // Define the array.
floatArray[0] = 1.0f; // Assign values one at a time to each index.
floatArray[1] = 2.0f;
floatArray[2] = 3.0f;
floatArray[3] = 4.0f;
floatArray[4] = 5.0f;
floatArray[5] = 6.0f;
Keep in mind that Arrays are of fixed length. The 0th index is always the first index in the array.