- Home /
              This question was 
             closed Aug 20, 2012 at 05:14 PM by 
             tigerfoot for the following reason: 
             
 
            The question is answered, right answer was accepted
Vector direction to point
How do i convert Debug.DrawRay to LineRenderer?
 var lineRenderer : LineRenderer = GetComponent(LineRenderer);
 
 var aimEnd2 : Vector3;
 aimEnd2 = (aimStart - currentTouchPos).normalized;
 Debug.DrawRay (aimStart, aimEnd2*Vector3.Distance(aimStart, currentTouchPos), Color.blue);
 lineRenderer.SetPosition(0, aimStart);
 lineRenderer.SetPosition(1, aimEnd2*Vector3.Distance(aimStart, currentTouchPos));
That last line is not drawing Line Renderer properly. I know that's because DrawRay uses direction and LineRenderer.SetPosition is using exact point but i really get confused quickly when using vectors :)
The blue line is from DrawRay and the big one is from LineRenderer 
How can i convert that direction into the exact point in space? I hope the question isnt too confusing.
 
                 
                screenshot001.jpg 
                (23.7 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Khada · Aug 20, 2012 at 05:00 PM
If you know the start position, direction and distance, you can calculate the end with ease:
 Vector3 vStart = X; //wherever the line starts
 Vector3 vDirection = X; //whatever your dir is
 float fDistance = X; //whatever your dist is
 
 Vector3 vEnd = vStart + (vDirection.normalized * fDistance);
$$anonymous$$an, i hate vectors... Works perfectly, thanks
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                