Hi, I found only bugs on Unity 5. When the game starts, The AI have to find the GameObject of the Player.
private Transform GetRandomTarget()
{
GameObject[] persons = GameObject.FindGameObjectsWithTag("Player");
int t = Random.Range(0, persons.Length);
return persons[t].transform;
}
And on unity 4.6 the code works fine, But on unity 5 it is gives me problems. The error:
I found the way that, But it doesn’t work well. The way is to re-click again of the tag which the Player object has.
Any ideas?
Someone? Where Unity Support? I can’t keep working on my Project.
GameObject.Find also doesn’t work. What the hell happens here?
system
March 5, 2015, 2:23am
4
We’ll have a look. Could you please file a bug also? Thanks.
If Unity crashes whenever you open a project, that usually means one or more files got corrupted in your Library folder. So go to your project folder (where Assets and Project Settings are), delete a Temp folder if it exists, and then the Library folder. Note that when you next open the project in Unity, all assets will be reimported, which could take a while if you have a lot.
As for reporting bugs, in Unity, go to the Help menu at the top and choose “Report a bug…”.
Maybe random.Range(min,max) changed in Unity 5 so that max is inclusive?
It doesn’t have to be inclusive, maybe there are just no objects with tag “player”, so random(0,0) will get you persons[0], which is nonexistent.
GameObject.Find() should work, too. I would assume that you do this somewhere at level start and your player is not initialized yet.
Dreamzle:
If Unity crashes whenever you open a project, that usually means one or more files got corrupted in your Library folder. So go to your project folder (where Assets and Project Settings are), delete a Temp folder if it exists, and then the Library folder. Note that when you next open the project in Unity, all assets will be reimported, which could take a while if you have a lot.
As for reporting bugs, in Unity, go to the Help menu at the top and choose “Report a bug…”.
Maybe random.Range(min,max) changed in Unity 5 so that max is inclusive?
It doesn’t have to be inclusive, maybe there are just no objects with tag “player”, so random(0,0) will get you persons[0], which is nonexistent.
GameObject.Find() should work, too. I would assume that you do this somewhere at level start and your player is not initialized yet.
Thanks for the answer!
I talked with Unity Support and them told me It happens because I called the function from Awake function.
I fixed it.
Again thanks.
1 Like
RSH1
July 17, 2015, 1:12pm
9
I’m getting this error when using FindGameObjectsWithTag on iOs from an InvokeRepeating method
UnityException: Tag: Mob is not defined.
when it IS defined, and works perfectly well in the editor.
deLord
August 16, 2015, 8:51am
10
got the same issue.
I am calling it from my OnLevelWasLoaded method where it runs perfectly fine in my Editor but not in exe or WebPlayer.
Then I tried shifting everything into a coroutine that calls this stuff after 1 frame, so everything should be there, right?
Same! It freaking gives me “Opponent not defined”. This bug is so crazy since this method is so important
deLord
August 19, 2015, 7:27pm
11
Found the solution here
It comes when you upgrade older projects (in my case from a beta 4 to 5). Your editor will still display the tag of your GO, but when you click “add tag” you will notice that this tag list is empty !!!
Just re-adding the tag and assigning it EVERYWHERE again solves the problem. Good god, this bug gave me nightmares
1 Like