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?