- Home /
Unity RaycastHit.transform.tag working in editor not working on Android
Hi,
So here is my script
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.tag == "Ground")
{
The function works perfectly within the editor but doesn't work on android build. Without the if statement checking for the tag, the function works on android as well.
It only doesn't work when I have set a custom tag to the gameobject. And it only stop working if I try to access the tag name via script.
Answer by KKS21199 · Mar 05, 2017 at 02:16 PM
It's working. It seems that when you remove a tag from the tag manager and then build the apk without restarting unity, this problem happens. I guess its a bug. Simply closing Unity and reopening got it working. Then i tried removing a tag and built an apk and it gave me the same problem. I once again closed the project and reopened it and everything was working fine.
This was my issue. I checked the list of tags and there was one that said removed that wouldn't remove itself. So I added another tag, deleted it, then restarted and both were gone. Thanks for your help $$anonymous$$avanas, I spent 3 hours questioning my ability to dev before seeing your post!
Thanks $$anonymous$$avanas, it took me one day debugging all of my client and server code. You saved me a lot of time. How can we report this bug?