- Home /
 
               Question by 
               $$anonymous$$ · May 22, 2021 at 09:19 AM · 
                raycastphysics2draycastingraycasthit2dlayermask  
              
 
              Why is RaycastHit2d Not working
I am trying do raycast on layers , but it is showing hitpoint = 0 evry time: here is my code
 void Update()
 {
     Vector3 mousePOsition = Camera2d.ScreenToWorldPoint(Input.mousePosition);
     mousePOsition.z = 5.7f;
     Vector3 Direction = mousePOsition - transform.position;
     
     float angle = Mathf.Atan2(mousePOsition.y,mousePOsition.x) * Mathf.Rad2Deg;
     Ref.transform.rotation = Quaternion.Euler(0,0,angle);
     
     RaycastHit2D hitwall = Physics2D.Raycast(Ref.transform.position,Ref.transform.right , 20 , WallLayer);
     Debug.DrawRay(Ref.transform.position,Ref.transform.right*20 , Color.white);
     RaycastHit2D hitFloor = Physics2D.Raycast(Ref.transform.position,Ref.transform.right , 20 , FloorLayer);
     Debug.DrawRay(Ref.transform.position,Ref.transform.right*20 , Color.white);
     
     
     print(mousePOsition);
     
     if(hitwall.collider != null )
         print(hitwall.point);
     if(hitFloor.collider != null)
         print(hitFloor.point);
 }
Can Some one tell me hat is wrong
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                