- Home /
 
 
               Question by 
               mourad277 · Aug 20, 2017 at 02:25 PM · 
                raycastraycasthitraycasthit2dlinecast  
              
 
              Problem with raycast vertical
Hi please help me i need send raycast like a line but if drawing this ray not like a line
     Ray ray2 = new Ray(transform.position, new Vector3(transform.position.x, 50, 0));
      RaycastHit hit2;
      //Debug.DrawLine(ray2.origin, new Vector3(transform.position.x, 50, 0));
      Debug.DrawRay(transform.position, new Vector3(transform.position.x, 50, 0), Color.red);
 
               
 
                 
                raycat-problem.png 
                (28.8 kB) 
               
 
              
               Comment
              
 
               
              Answer by Kishotta · Aug 20, 2017 at 07:24 PM
So I think you may not be using the Ray constructor properly. You don't need to calculate the ending location of the ray. Just the direction it should face.
Try:
 Ray ray2 = new Ray(transform.position, Vector3.up);
 Debug.DrawRay (ray2, Color.red)
 
              Your answer
 
             Follow this Question
Related Questions
RayCast2d Not colliding with objects in other layers 1 Answer
Raycast Not Working 3 Answers
Physics.Raycast not hitting anything 1 Answer
Ray is not being detected 0 Answers