Fixed distance from point


I need to generate a point from another fixed point that has a fixed distance. The point must be the closer point to the player. So If I have a start point 0,0,0 the nearest point to the player that is 10 feet distant from 0,0,0.

let’s say point a is the origin, point b is the player and d is the distance you want.

Then the resulting point is
p = a+(b-a).normalized*d

(b-a).normalized should return a vector that is the direction from a towards point b. we normalize it to make it length 1.

We multiply it with d so it gets the right length.
And we add it to point a because we want its position to be relative to a.