- Home /
 
               Question by 
               mcdemrer · Aug 08, 2017 at 10:04 PM · 
                raycastvector3raycastinglinerendererreflection  
              
 
              Only One LineRenderer Renders
I have two individual LineRenderers, one based on a Vector3.Reflect() of the other, but my code will only render the most recent one in the code. Any ideas?
Draw Code
 public static void Fire()
 {
     staticAlpha = 1;
     AmmoHandler.GlockAmmo = AmmoHandler.GlockAmmo - 1;
     Vector3 rayDir = staticTransform.TransformDirection(Vector3.forward);
     Vector3 startPoint = staticTransform.position;
     if (Physics.Raycast(startPoint, rayDir, out hit))
     {
         staticAlpha = 1;
         staticLineRenderer.SetPosition(0, startPoint);
         staticLineRenderer.SetPosition(1, hit.point);
         Vector3 rayDir2 = Vector3.Reflect(hit.point - startPoint, hit.normal);
         Vector3 startPoint2 = hit.point;
         GameObject objectHit = hit.collider.transform.gameObject;
         if (Physics.Raycast(startPoint2, rayDir2, out hit2))
         {
             staticChildLineRenderer.SetPosition(0, startPoint2);
             staticChildLineRenderer.SetPosition(1, hit2.point);
             GameObject secondObjectHit = hit2.collider.transform.gameObject;
         }
     }
 }
Color and Render Code
 public static void RenderLine()
 {
     if (GO.name == "CalculatorGun") {
         staticAlpha -= Time.deltaTime * 3;
         Color start = staticLineRenderer.startColor;
         Color end = staticLineRenderer.endColor;
         Color start2 = staticChildLineRenderer.startColor;
         Color end2 = staticChildLineRenderer.endColor;
         start.a = staticAlpha;
         end.a = staticAlpha;
         start2.a = staticAlpha;
         end2.a = staticAlpha;
         staticLineRenderer.SetColors(start, end);
         staticChildLineRenderer.SetColors(start2, end2);
     }
 }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                