Answers for "how o make the ray ignore a layer"

1

raycast ignore layer

public LayerMask IgnoreMe;
     private Ray ray;
     private RaycastHit hit;
 
     void Update()
     {
         if (Input.GetMouseButtonDown(0))
             NeroFiresEverything();
     }
 
     public void NeroFiresEverything()
     {
         // Basic example ray
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 
         if (Physics.Raycast(ray, out hit, 1000f, ~IgnoreMe))
         {
             Debug.Log("Get Rekt " + hit.collider.name);
         }
     }
Posted by: Guest on October-05-2021

Browse Popular Code Answers by Language