- Home /
Find position of point beetween two objects on certain distance
Hello, maybe this question is a bit dummy. I'm not very good in math.
My problem is in topic title. A picture is attached to show it. I have mouse position, ball position and line length. I want to know point position at the end of line. And when I move mouse, that point changes.
Answer by drudiverse · Jun 26, 2014 at 12:00 PM
You save time if you look at the unity answers, try 2-3 searches on same topic with similar phrases.
you can make a line of XYZ length by doing position A minus position B
var line = objecta.pos - objectb.pos
That way you have a line going from one to the other.
if you want halfway, do:"
var newdistance = (line.x * .5,line.y *.5,line.z*.5) ;
then add that to object a to find point between":
new point = newdistance + objecta.pos;
I am sure i asked the same question once, and so did everyone, except perhaps i found it on the forums using google search i dunno. it's not so obvious.
c u
Also there is Vector3.Lerp. You can use it if distance of line is a fraction of distance between objects.
Your answer
Follow this Question
Related Questions
Reposition to minimum distance from target 2 Answers
distance to variable object 1 Answer
how do i fix my script in the content below? 0 Answers
Position on a Vector3 at specific distance 1 Answer
Return to Start Position 1 Answer