public Vector3 z = new Vector3(0,28,0); //it's a Y coordinate, I know
public Vector3 maxroll = new Vector3(0,95,0);
void Update () {
if ((Input.GetAxis("Mouse ScrollWheel") < 0) && ((maxroll[1]-z[1])<= 67)){ // mousewheel back
transform.position += (z*0.2f);
}
}
So my problem is, even when the y-coordinates’ distance is way above 67, it doesn’t stop the if-condition. But if I say:
“<= 66”, the mousewheel won’t work.
I suspect that the y-coordinate (the z-vector) simply isn’t updated.
I hope someone has a solution, and thanks for reading even if you don’t
If I’m understanding this correctly, you want to move the object that this script is attached to upwards in the y direction until it reaches the maximum position.
In that case, your two variables aren’t changing at all, so maxroll[1]-z[1] will always return 67.
What you need to do is use maxroll[1] - transform.position.y for the comparison.
(note: you can also use maxroll.y looks a little more clear in my opinion)