I have a script that reacts to the mouse going over certain trigger colliders (all 2D), but when I have a regular collider overlap with the triggers, the overlapping area no longer responds to the mouse. Is there anyway to resolve this? I’m trying to avoid putting the under the same object.
you can use layers and raycasts that ignore layers.
The issue is the regular collider is intercepting the raycast as it were.
raycastall might work as a kind of hacky thing.
raycast vs raycastall, raycast returns the FIRST object hit, raycastall penetrates and returns all objects.
Once you realize your issue is you’ve basically covered up your trigger collider in a blanket you realize you just need to make sure you fix that.
In this case you can either assign trigger colliders to Trigger layer or Mouse layer or whatever (name is arbitrary)and raycast only on triggers or you can assign regular collider to Regular Layer or whatever and exclude that layer from the cast, which is really a cast to all but.
Basically the cast will still hit the first trigger but then unity will do a “is this object’s layer such that it counts as an object this ray can hit?” if the answer is no then it ignores it and goes on until it hits one that counts.
This can have many uses, for example a raycast that ONLY hits terrain can be useful for a lot of reasons or a raycast that ONLY hits say the player. If all your interested is a certain individual or group of objects counting as valid targets, placing all those in a layer and only casting a ray against that layer is the way to do that.