Physics.Raycast(ray, out hit, 50) This raycast collides with a test object, but also collides with the player which is undesired. Physics.Raycast(ray, out hit, 50, LayerMask.NameToLayer("Player")) This one ignores the player but also ignores the test object. The test object is not using the player layer. I am so confused
The argument there is a bit-mask where each bit represents a layer, it's not a single layer. Try LayerMask.GetMask Effectively it's like doing: Code (CSharp): Physics.Raycast(ray, out hit, 50, 1 << LayerMask.NameToLayer("Player"))