And that is determined by how massive the star has to be and how close you have to get to it in order to deflect this velocity V change your velocity from plus V to minus V, zooming you back towards Earth. 