I’m trying to use raycasting to get the location of the mouse on the surface of a cube. However I can’t figure out how to get the raycast to ignore all other colliders. I looked at the unity script reference for Collider.Raycast at Unity - Scripting API: Collider.Raycast but I still don’t understand where you declare which collider the ray should be looking for. Any help would be greatly appreciated.
The way to do it is to put the cube in a layer by itself and then use Raycast() with a layermask parameter with only that layer enabled in the mask.
You could put the cube into that layer just before the test and then add it back after so you don’t have to maintain identical collision masks in the physics settings.