I am moving my plane. But it should only move between two positions like -20f to 20f.
I am using this logic
if(plane.transform.position.x >= -20f && plane.transform.position.x <= 20f)
{
if(Input.mousePosition.x< 0)
plane.transform.Translate(-Vector3.right * speed * 2 * Time.deltaTime);
else if(Input.mousePosition.x > 0)
plane.transform.Translate(Vector3.right * speed * 2 * Time.deltaTime);
}
The problem is it is going beyound 20f… i.e. it goes to 20.06… and then it stops because now it willl not enter inside this condition.