There are multiple ways to do that, depending on what kind of curve you want.
For example bezier curves:
The logic behind them is that, you take three points that define your curve. The first point is the beginning of the curve, and the last one is the end of the curve. The other is a "control point" meant to give the curve its shape.
To calculate this, you need to be familiar with a function like
Lerp, which is used to find a point that lies between two other points. Following that, you end up with this:
// The points of the curve
Vector3 P0, P1, P2;
// time going from 0.0f to 1.0f
Vector3 pointInCurve =
Vector3.Lerp(Vector3.Lerp(P0, P1, t), Vector3.Lerp(P1, P2, t), t);
The logic behind it is: Assuming you have a variable
t that says at which position on the curve you currently are, find the point between
P1, depending on
t, so that in the beginning it's closer to
t (so closer to
P0) and as time passes, it goes closer to
1 (so closer to
P1). Do the same for another point that goes from
P2. These are the two green points illustrated on the gif.
Then do the exact same thing, for finding your desired point, which is now between the two green points. The result is the black dot on the gif, following the red curve/path.
You can follow the same logic to do quadratic bezier curves:
Just take 4 points instead of 3, calculate all the in-between points, until you end up with 3 new points, which then you can treat as a regular bezier curve and follow the steps above. In fact this way you can have as many points as you want.
There's also the Catmull-Rom curves:
They follow a similar logic, they have 4 points, but here the path travels from the second to the third point, using the first and last as control points. I've used this one before to simulate a "path" a flying creature is following, as when it reaches the end of that curve, you can create a new curve using points 2, 3 and 4, and generate one last point towards the direction that you want, so the path is smooth.
Unfortunately my familiarity with how these curves work behind the scenes is limited, but you can read more about them in Wikipedia - Centripetal Catmull–Rom spline.
Once you get the hang of how curves work, you can experiment with how fast
t is updated to create effects like in easings.net.