Raycast through my collider

Hello all;

I’m casting an array from my player as follows:

	if(isLerping == false && canturnagain == true){  //turning right
		if (Physics.Raycast (transform.position, -transform.right, hit2, 2.1)) {
		   	if (hit2.collider.tag=="Turn2"){
		   	//Debug.Log("non");
		   	turnright = true;
			turnR = true;
		   }
	    }

However; I’m casting this ray at an object that is inside/alligned with another collider which means the ray doesn’t hit the Collider with the tag Turn2.

Is there any way to disable objects from being hit from a raycast?

Thanks, Bobblehead.

You can put the colliders/objects you want the raycast to ignore in the “Ignore Raycast” layer. More information about layers can be found in the docs:

http://docs.unity3d.com/Documentation/Components/Layers.html