I work on a set of circle used for the rotation of a cube (as the tool rotation 3DS Max).
I placed my graduation in the middle of the current cube. The problem is that the cube have also a collider (used for raycast), I can not get one of the circles of graduation (located inside the cube).
I try the following without success:
// disable Raycasts
gameObject.layer |= 1<<2;
// enable Raycasts
gameObject.layer &= ~(1<<2);
=> no result …
and GameObject.collider.active or .enabled are obsolete method.
I find Physics.RaycastAll to get all the collider under the raycast but i dont know if it’s the best way. I would prefer disable the cube collider…
I need some help
You could put each type of object in separate layers, then just specify a layer mask when calling Raycast. Then it will only return a hit for an object in the specified layer.
I'm using a similar scheme on my current iPhone prototype; each object has a collider used for game object collisions, and larger sphere colliders I use only for touch-selection that completely contain the physics colliders. The spheres are in a layer called Selectable, the smaller ones in Obstacle. Used the collision matrix (edit->project settings -> physics) to set up the Selectable layer not to collide with anything else, and my raycasts on touch just specify the Selectable (it's layer 9, in the script I define a "static var SELECTABLE:int=1<<9;" and pass that as the layermask parameter to Raycast. Works like a charm!