Object follows point while projecting on a line

Hi everyone,

I have been trying for weeks to find a solution for this problem, but my basic knowledge of vectors makes it very frustrating

I have two points (A and B) which are going to set a patch for a projected point (red dot). The red dot needs to follow point C (being on the same X-axis).

I have tried Vector3.project, but it makes the red dot perpendicular to point C.

projectedPoint = Vector3.Project((C - A), (B - A)) + A;

Does anyone how to fix this? I am sure that the answer must be simpler than I think, but I couldn’t find any post related to this.

Thank you in advance.

I found the answer :-D.

The idea is to find the y-coordinate (as we know the x from C). I found the answer here:

https://stackoverflow.com/questions/48452332/trying-to-find-2d-coordinates-of-point-along-straight-line-given-one-coordinate

so, instead of using a Vector3 projection, it would be finding the place for the red dot.