Mouse Click + Raycast + Colliders

I’ve got code that instantiates a laser where the user clicks. However, I have large trigger colliders which are used to detect the player…The mouseclick is registering that it’s clicking the invisible trigger and thus when you can’t shoot from within the collider. The only info I found was to Edit > Project Settings > Physics > Uncheck “Queries Hit Triggers”, but this fix did not work.

Here is the code that shoots the laser:

                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    Vector3 pos = shootFX.transform.position;
                    Vector3 dir = hit.point - pos;
                    Instantiate(laserPrefab, pos, Quaternion.LookRotation(dir));
                    laserShot.Play();

                    anim.SetTrigger("Shoot");
                    shoot();
                }

How can I make the mouse ignore the triggers and shoot where I actually click?

Click on your trigger, click on layer and select ignore raycast.

You can raycast on specific layers, so if you create a public LayerMask variable, move your triggers to unchecked layer and raycast through that layermask you won’t hit objects on unchecked layer.