I want my raycast to ignore the particles made from the character and then stop at the next collider. I have added the particles to a layer named “particles” and the raycast is made to see if the player is in front of the character although now the character can see through the walls, which is not good. How can I make the raycast ignore the particles and then make the next collider it hits be applied to a variable that I can use in a if()-statement to see if its the player? I have looked in the docs.unity without success, any answer or reference much appreciated.
Just select Layer “Ignore raycast” for the particular object to not affect your raycast so the u can find the object behind it.
Typically this is done by placing object on different layers (as you have done with “particles”). Then you use a layer mask in the Raycast() call. A layer mask is a set of bits, with one bit per layer, so you can set the mask so that the Raycast() can see only the layers you want it to see. That is the mask allows the Raycast() to see multiple layers while at the same time excluding some layers.
This post here will give you info on constructing layer masks:
http://answers.unity3d.com/questions/8715/how-do-i-use-layermasks.html