how to instantiate an object each time there is a certain amount of increase in the y position of another object?

hi everyone…i am trying to instantiate an object(x) each time there is an increase in y position(lets say each time the y position increases by 4, INSTANTIATE ) of another object(a ball) OR each time there is a certain amount of increase in vertical distance between the Ball and another obeject(y) which stays on the ground and not move…how can i do any one of these…plz help

public int iY; //Original position
public int dY; //Step for instantiating

public void Start()
{
	iY = tranform.position.y;  //Set original position
}

public void Update()
{
	if (tranform.y > iY + dY)
	{
		iY += dY;   //Reset original position
		Instantiate();
	}
}