I’m a begginer with programming and Unity. My question is:
Is it possible to store different values of the same variable? For.e.
I’ve got values for “rotation.x” and “rotation.y” that are constantly changing. Can I store that values in a moment of time inside variables? So I can compare/operate with other values of the same variables in the future. How?
what I try to achieve is: when the difference between rotation1.x and rotation2.x is positive/negative, change the position of an object to one side or another.
I tried with coroutines, but maybe im doing something wrong.
Yes, this is absolutely doable and it’s very common to use in programming.
The thing that you need is Lists, and you can store multiple values of the same data type.
This is how you initialize the list
List<float> tempRotationsList = new List<float>();
Then you store data to a list by doing this
tempRotationsList.Add(rotation.x); or tempRotationList.Add(rotation.y);
And you do this for every data type, just the value and type have to match. So you cannot add integers to the list of strings, but you can always convert them.