Question by 
               emircuneyta · Jan 20, 2021 at 07:45 PM · 
                lineaimglonpostrender  
              
 
              How to scale lines lenght drawn with OnPostRender and GL
Hey guys,
I've been trying to scale lines length drawn by GL lines. My script basically draws a line between a constant point and my mouse cursor. So let's say the constant point is (0,-4,1) and my mouse is at (1,5,1) My goal is drawing the line from the constant point and just draw let's say 0.5 maximum towards to mouse position.
  void Start()
     {
         objectPosition = positionObject.transform.position;
     }
 
     void Update()
     {
         mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
     }
 
     void OnPostRender()
     {
         if (!mat)
         {
             Debug.Log("Please Assign a material on the inspector");
             return;
         }
 
         Debug.Log("drawing line");
 
         GL.PushMatrix();
         mat.SetPass(0);
         GL.Begin(GL.LINES);
         GL.Color(Color.red);
         GL.Vertex(mousePos);
         GL.Vertex(objectPosition);
         GL.End();
         GL.PopMatrix();
     }

with the image, I think it's more clear. black one is the one in my game. red one is basically the black one( I don't know why I added that too) green one is the one I want.
I need the line as long as what I want, not until the input's location. It's suppose to be like a aiming line.
Thanks a lot!
 
                 
                screenshot-2021-01-20-at-9.png 
                (9.3 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                