- Home /
How to make cubes between 2 point and stick them together?
Hi all. I have a function which gets 2 points and creates a scaled cube between them. the problem is: however the points are back to back I see some gaps between cubes sometimes. What's wrong with my code? Here's my code:
 private void drawWay(DoubleVector3 point1, DoubleVector3 point2) {
         var dir = point2 - point1;
         var dirVector3 = DoubleVector3.ToVector3 (dir);
         var mid = point1 + (dir) / 2.0;
         var scaledMid = DoubleVector3.ToVector3(mid * scale);
         var angleToRotate = Math.Atan2 (dir.z, dir.x) * (180 / Math.PI) * -1;
 
         if (coordinateShift.x == 360.0f && coordinateShift.z == 360.0f) {
             coordinateShift.x = scaledMid.x;
             coordinateShift.z = scaledMid.z;
         }
 
         var yzScale = scale / 40000.0f;
 
         var position = scaledMid - coordinateShift;
         var rotation = Quaternion.Euler (0.0f, Convert.ToSingle (angleToRotate), 0.0f);
         var localScale = new Vector3(dirVector3.magnitude * scale, yzScale, yzScale);
 
         var clone = Instantiate(way, position, rotation);
         clone.transform.localScale = localScale;
     }
And here is the gap between 2 cubes:

 
                 
                result.png 
                (89.3 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                