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.
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.