I would like to create a “Gravity Grid” such as in this image:

The closest I have been in creating this grid is shown in this image:

I’m only warping the lines parallel to the Y-Axis until I can solve this problem. But as you can see in the picture, the lines seem to be warping past my “planet”.
Here is the code of interest I have for now:
for (each point on a line parallel to the y-axis) {
if (planetPosition.x > currrentPoint.x) {
warpedXPos = currrentPoint.x + (1 / (distance*1000));
}
else {
warpedXPos = currrentPoint.x - (1 / (distance*1000));
}
}
The idea is to pull every point towards the planet by an amount proportional to 1/R, where R is the distance from the planet to the point.
In your code you currentPoint.x, etc, is the absolute position, but you need to warp the position relative to the planet. Therefore your equation should look like:
The part after the
+is the scaling of the relative distance basically your warp, and then you add this deflection to the original absolute value. You probably also won’t want to use the 1000 factor, but this is just keeping with your example. Also, note that there’s no need to break this into cases using the>, the sign of the subtraction should make the adjustment in the appropriate direction.(By the way, this type of operation is super common… first you subtract an absolute factor, then you scale, then you add the original factor back in. It’s a trick worth memorizing for use in lots of applications.)