Finding a point on a line that intersects a circle

I’m having difficulty with remembering how I did this kind of math in high school, and how to turn that math into C++. I have the location of “Actor 1”, and the location of “Actor 2”, both of which are inside of radius “r”. Actor 1 is always at the center of this circle, and wherever Actor 2 is inside the circle, I need to find the point where the line that can be drawn through the two intersects the circle’s edge. I know that technically, such an equation would yield 2 places where the line would intersect the circle, but I need the point behind Actor 2 (it would technically be the point of the two that is closer to Actor 2, if that hint helps). I made a picture to illustrate this.

285689-theillustration.png

I’m only going to worry about doing this in 2 dimensions, by the way, so forget about the Z-axis.

subtract actor B’s position from actor A’s position then normalize the result to get the unit direction vector(or use the GetDirectionUnitVector function from the math library), then multiply the direction by the radius of the circle and add actor A’s location.

Thank you so much! I’m also thankful you didn’t ask to see my atrocity of a script. For those who want to know what this looks like in C++:

#include "Kismet/KismetMathLibrary.h" //Make sure to put this with your includes

//...

//Declare and define these wherever appropriate
FVector NewLocation;
FVector Actor1Location = Actor1->GetActorLocation();
FVector Actor2Location = Actor2->GetActorLocation();
float Radius = 500.f;

//Get the unit direction vector
NewLocation = UKismetMathLibrary::GetDirectionUnitVector(Actor1Location, Actor2Location);

//Then multiply that direction vector by the radius and add Actor1's location
NewLocation = (NewLocation * Radius) + Actor1Location;

//Set the new location of the target point
TargetLocation->SetActorLocation(NewLocation);