- Home /
Check the length of a line renderer?
I created a script that makes a line renderer in the 3d world space..
for example,
(these are the positions of the line renderer)
position 1 : 50x, 80y, 0z
position 2 : 80x, 120y, 0z
is it possible to calculate the LENGTH of the line renderer as a float? for example : line renderer = 156.7 units...
Please help =)
P.S. THE REASON I am having trouble finding the length of the line renderer is because there are both x AND y values, if it was just X values, I could for example say... that the length is 30 units/pixels (using the example positions above) BUT since there are two values, the line renderer is diagonal...making it hard to find the length!
EDIT : Im just trying to convert the Vector positions into a float value.
Answer by robertbu · Jul 20, 2014 at 03:24 PM
Say position1 and position2 are Vector3 variables. You get the length by:
var length = (position2 - position1).magnitude;
Answer by ahmadian · Jan 03, 2016 at 09:06 AM
The Vector3 class has a method to calculate the distance of two vector3 :
float _Distance = Vector3.Distance(Position1,Position2);
Your answer
Follow this Question
Related Questions
Half a pixel? 0 Answers
GUI To change with screen resolution? 2 Answers
how to scale and position guiText in android 1 Answer
How do I get the filesize of a file on the user's hard drive? 1 Answer