using Transform on a Object will not move it 100% exactly...

Im pretty new to unity, but this thing has been bugging me for a bit.

	if(posZ < max){
		transform.position += new Vector3 (0, 0, Time.deltaTime * cubeMoveSpeed);

say the max is … 3, what will happen is that the object will move smoothly to 3.013413241 …

So while it is at 3.0 or 3.1, within that range anyway, it will not exactly stop at 3.00000

… so is there anyway to fix this?

I was thinking you could potentially check if the object is in very close proximity to a number and then just place it exactly there but… that sounds like unnecessary work, but who am I to know… im just getting started learning.

You are using Time.deltaTime, which you should, this though is a float value and will introduce a small amount of in-precision as a result. You need to put an “else” condition following on from your initial “if” which will then set the position exactly when the posZ is not < max. Better still check if the new position is going to be more than “max” before you move the position, then(if it is) you move exactly to the point(3.0).