- Home /
Bizarre hit.collider.tag behavior
So I'm executing statements based on collider tags after ray casting. No biggie, right? Problem is, they're switched up. I've got the following two debug lines:
Debug.Log (hit.collider.tag);
Debug.Log ("tag == floor: " + string.Compare (hit.collider.tag, "floor"));
It will literally print out "floor" on the console because of the first statement, and return false on the second statement.
Even stranger, I have another object tagged NPC, right? If I click on it, the console spits out "NPC", and the second statement returns true.
What is going on here?
Update: Even stranger, if I test the string in a dedicated method, the comparison works exactly as one would expect. It's an easy workaround, but I'd still like to know what's going on here.
Your answer
Follow this Question
Related Questions
A limit to the number of tags? 2 Answers
Having trouble with raycast detecting enemy 1 Answer
Possible Unity BUG? Or am i missing something 1 Answer
4.5.2 animation BUG: 2D collider colliding with 2d trigger!!! 0 Answers
Raycast shooting problems 1 Answer