- Home /
 
 
               Question by 
               powerpixelsoftware · Oct 09, 2016 at 02:15 PM · 
                editorrenderingplaymodegizmosline drawing  
              
 
              Draw line on play gets distorted
Hi everyone,
Here is the problem, check the screenshots: 
 and 
 So this happens after I enter the play mode. What is it all about? I have made a custom spline editor for path finding, everything works well except this visual issue. Everything is drawn in the OnDrawGizmos().
Here is a piece of code I use to draw all the elements:
 for (int i = 0; i < BezierCoordinates.Length; i++)
     {
         t = i * fraction;
 
         p0pos = Point0.Position;
         p1pos = Point1.Position;
         p2pos = Point2.Position;
         pointCoords = ((1 - t) * (1 - t)) * p0pos + 2 * (1 - t) * t * p1pos + t * t * p2pos;
 
         BezierCoordinates[i] = pointCoords;
 
         if (i != BezierCoordinates.Length - 1)
         {
             Gizmos.color = PathLineColor;
             Gizmos.DrawLine(BezierCoordinates[i], BezierCoordinates[i + 1]);
         }
 
         if(drawSteps)
         {
             Gizmos.color = PathPointsColor;
             Gizmos.DrawWireSphere(BezierCoordinates[i], PathPointsSize);
         }
 
         Gizmos.color = PathLineColor;
         Gizmos.DrawLine(BezierCoordinates[BezierCoordinates.Length - 1], p2pos);
    }
 
               Any suggestions? Hope to hear from someone! And thanks in advance.
 
                 
                editor.png 
                (60.7 kB) 
               
 
                
                 
                playmode.png 
                (70.4 kB) 
               
 
              
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by powerpixelsoftware · Oct 10, 2016 at 10:59 AM
This was happening because I had another method which did the same as the one above. I was updating points in two places, in Update loop and OnDrawGizmos, this was the issue. Now it's only in OnDrawGizmos and now it works fine.
Your answer