- Home /
RayCastHit returns Untagged for a Tagged Item, when using a Mesh Collider.
Hi guys, I am very new to Unity. I am trying to use a RayCast to identify the tag of the floor components beneath the player in the AngryBots Demo. I have a RayCast going down from the player, and the floor is tagged "Floor". When I run the game, I get "Untagged". When I use a Box Collider, it works correctly, but my surface isn't a cuboid shaped object, and I can't afford to have it enclosed in a box collider. If I use a mesh collider, I get "Untagged". I don't really know how this works, and I haven't been able to find an answer that explains how this works.
Hi there, Did you get an answer to this?, I have a similar problem: when I cast a raycast over a tagged mesh collider, it seams it goes through, doesnt catch anything.
Answer by sriram90 · Mar 21, 2014 at 07:30 AM
Not sure what the problem is going on. I tried with Box Collider as well as mesh collider, both working like charm.
void Update()
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out hit, 500))
{
print ("hit : "+hit.collider.gameObject.tag);
}
}
Check with your code if anything is missed. Just try with Enabling Convex in Mesh Collider.
Note : Try to check anyother object in background. for Eg., Cube is in front, may another cube will be in backside with out tagging.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085056im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Raycast isn't comparing tags 1 Answer
Raycasting will not hit some imported meshes with mesh colliders? 2 Answers
Does work the raycast on a mesh collider? 3 Answers
RaycastHit always returns 0 1 Answer
C# raycast shooting script broken 1 Answer