As the title suggests I need to find a Point on a Ray which is at a certain distance from another specified point (Vector3.zero in this case).

More info :
I am trying to make a Draggable Sphere around a planet which ALWAYS maintains a 5 unit distance from the Center (Vector3.zero) and cannot be dragged beyond that.
Dragging it closer to the Planet will only make it hover and travel in the direction of the drag.

Hi, you should read some doc about vectors & stuff.

Here is what you are looking for :

Vector3 point = centerOfSphere + ray.direction * 5.0f;

You add to the origin point the vector which will give you your final point. You want to follow the ray so you get its direction (it is normalized, so its magnitude is 1) and you multiply it by the distance you want to travel (here 5 units).

Make the sphere a child object of a child object of the planet at exactly 5 units away along the z axis and just put a LookAt script on the sphere’s parent to look at a dummy object that is always synced to the mouse pointer. That should give you the effect you are looking for with the least effort.

You need the point on the ray, that is closest to your origin. Measure the distance and then you can calculate the two points (it’s always two) on the ray that are 5 units from the origin (you get the distance between the closest point and your wanted point by way of the theorem of Pythagoras). But I am not sure this will help you at all…

What I would do, is calculate the distance between the sphere and the planet, and if it is bigger or smaller than a certain threshold, you set it to be that exact threshold.

Example:
var maxDist : int;
var minDist = int;
private var direction : Vector3;