My layers seem to be completely broken
Hi so I've been using ray-casts and layers fine for the past few months in a project of mine, but now they seem completely unpredictable and broken.
To make sure I wasn't going completely insane I created a new scene with just a cube in it, I gave the cube a different layer and tested the outcome multiple times.
So I made a script so that when I right click on the cube, I print out what layer I hit. Here is the result for the "Default" layer.
(the 12 results for "ray hit cube" is for layers that don't even have names yet I presume)
Also here is the script I'm using to test this, along with my layers
public class LayerTest : MonoBehaviour
{
void Update()
{
if (Input.GetButtonDown("Fire1")) //user has just clicked LMB
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
for (int i = 0; i < 32; i++)
{
if (Physics.Raycast(ray, out hit, Mathf.Infinity, i))
{
Debug.Log("ray hit " + hit.transform.name + LayerMask.LayerToName(i));
}
}
}
}
}
I am using unity 5.4.1, also if needed I can post the results for the rest of the layers, however only the following layers would prompt a print
Default
Ignore Raycast
TransparentFX
Water
Thanks in advance for any help.
Your answer
Follow this Question
Related Questions
RayCastHit 2d with layerMask not workin 0 Answers
How to make raycast only collide with two layers? 3 Answers
Unable to click UI button, tried everything I could find 1 Answer
Ignore Raycast not working properly? 0 Answers
Raycast hitting layer explicitly told to ignore (and doesn't even have collider!) 1 Answer