[solved] Survival Shooter - 'Player' tag mysteriously filled
I'm working through the Survival Shooter Tutorial for Unity 5.x - using the PDF adjustments. I have just finished adding the first enemy, who uses a Nav Mesh Agent to chase the player.
When I ran the program the enemy simply moved towards the origin point.
The player''s position is identified in the zombunny's controller script by the line "player = GameObject.FindGameObjectWithTag("Player").transform;" in awake and "player.postion;" in update So the first thing i tried doing was to log the player position.
The debug log kept returning even when i moved the player (0.0, 0.0, 0.0) so I tried changing both the player's tag and the searched for tag to "PlayerActual", this worked and made the zombunny chase the player.
I wanted to see what was wrong with the original however so I tried returning the code to it's original state and adding a new line using the FindGameObjectsWithTag command instead, this found a list of 6 objects (the last of which was my player)
The other 5 objects do not move from origin, i don't know how to find out other information about them. But the thing I've checked the project heirarchy and there is no other object in it with the player tag (i've even checked all the child objects of things like "Environment").
So my question is how can i find out more about these other objects, or how can i get rid of them?
Many thanks,
Martha
p.s. I can upload my project if that'd be handy
Answer by Lewance · Jan 15, 2016 at 04:05 PM
This turned out to be a bug or something in Unity, after rebooting my computer it was no longer there.
Answer by gameengineer2016 · Sep 08, 2016 at 10:42 PM
I had the same problem and I was following the tutorial word for word (as well as the PDF for Unity 5.x fixes). The Zombunny only headed for the origin 0,0,0 which is the starting point for the Player. The player position was not being updated therefore the Zombunny simply went toward the origin.
The fix was simply closing and restarting Unity. I don't think rebooting the PC was necessary.
Your answer
Follow this Question
Related Questions
How to correctly count number of objects? 2 Answers
Destroy gameobjects several times in a scene. Also destroy other instances of that gameobject. 2 Answers
How to get the tags of objects if they aren't in the scene? 0 Answers
I want my script to wait 2 seconds before continue in a condition, in update, using C# 2 Answers
Need help with c# 1 Answer