Hi to all. i have a problem with a taggged object.
i created a simple box and i tagged it as "box".
when i press on this object with mouse i obtain a tag name, but there are different points of the box that return me "untagged", also if i click on the box.
i use this function :
if(Input.GetMouseButtonDown(0)){
clickPosition = ScreenToWorld(Input.mousePosition);
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
int layerMask = 1279;
if(Physics.Raycast(ray.origin,ray.direction,out hit,100f,layerMask)){
selected = hit.collider.gameObject;
print(selected.tag);
}
}
someone can help me?
thanks.
↧