Question by 
               deXter_47 · Sep 03, 2020 at 07:27 AM · 
                raycastcolliderraycasthit  
              
 
              Need help with 2d shooting with raycast
I am working on a 2d top down shooter. Have added shooting with Physics2D.Raycast. For input directional controls I am using a virtual joystick. The raycast generated at the fire point is unable to detect any collider in it's path except for the character own's collider. I have checked the origin and direction of the raycast with Debug.DrawRay and it is fine. Here is the code I am using. Can someone please help.
 var hit = Physics2D.Raycast(new Vector2(FirePoint.position.x, FirePoint.position.y), FirePoint.transform.TransformDirection(Vector2.right), WeaponRange);
 
 Debug.DrawRay(new Vector2 (FirePoint.position.x, FirePoint.position.y), FirePoint.transform.TransformDirection(Vector2.right));
     
     if (hit.collider != null && hit.collider.name != "Player")
             {
                 Debug.Log(hit.collider.name);
             }
 
              
               Comment
              
 
               
              Your answer