- Home /
Non-existent gameObjects appearing.
Hey everyone. I've looked through the forums and nobody seems to have any answers to this, but the common factor seems to be the Mecanim Animator component.
So I have a player object with an Animator component, tagged "Player". Quite frequently when I try to reference it via FindGameObjectWithTag("Player"), it will find a non-existent gameobject in the scene called Player(Clone) that can't actually be found anywhere in the scene. It has a Transform and Animator components that can't be accessed or changed.
This happens practically every time I try to reference it, to the point where I've added a child object to the Player and referenced it instead, which even still occasionally references a non-existent clone. Does anyone know why this happens, and better yet a solution to this? I'm using v5.2.1f1, and scripting in UnityScript.
Answer by seth_slax · Oct 26, 2015 at 02:27 AM
Ok, so I'm not entirely sure what causes the problem (possibly just something in the way Mecanim works), but it seems to work if you reference tagged mecanim objects in the Awake() function as opposed to the Start() function. I've tested it a few times and it doesn't seem to throw errors or create non-existent references.
Some additional discoveries - This does work most of the time, however it seems changing anything in the Animator component (trees, states etc.) causes this to happen again. Saving/Exiting and reopening fixes the problem again. A bit of a pain though.
Answer by chaneya · Dec 30, 2015 at 05:07 PM
I'm having the same problem in Unity 5.3.0f4. I recently made a duplicate of my animator controller and I wonder is that has something to do with it.
Your answer
Follow this Question
Related Questions
Problems with Animator(Mecanim) 1 Answer
Can a Gameobject that is controlled by Animator be dragged by a non animator controlled object 1 Answer
Mecanim Transition-Arrow Pulsing 2 Answers
Get list of parameters of an AnimatorController 3 Answers
is it possible to read states / transitions from mecanim in runtime ? 2 Answers