Distance and mass affect gravity. If an object has a greater mass, it's gravitational pull will be stronger. And if an object is further away from the one that is exhorting the gravitational pull, then the gravitational pull on the object will be weaker than on closer objects.