Player(Clone) being instantiated?

Hi, I’m getting this weird bug today with Unity, where my enemies are looking towards an object called Player(Clone) at 0,0,0. When I check the 0,0,0 Coord, there’s nothing there and there’s nothing in the hierarchy.

The code to find the player is this

void Start () {
        target = GameObject.FindGameObjectWithTag("Player");
}

and under that I have

Debug.Log(target.name + " " + target.transform.position.ToString());

This prints “Player(Clone) (0.0, 0.0, 0.0)”

I restarted Unity and it fixed it, but then it came back, so is this a bug with Unity? I’m on version 5.3.4f1

Cheers, Anthony.

Edit: I have a feeling the bug is to do with the animation system, and I just noticed there is a newer version of Unity, this might fix it.

Edit 2: Found this on the Unity 5.3.5 patch notes

  • Animation: Fixed crash when GameObject with Animator is instantiated in StateMachineEnter/Exit. (770045)

Which looks promising.

Edit 3: Didn’t fix it, but I’m pretty sure it has something to do with the animation system, because the bug only happens when I change something to do with my Players’ animation.

Edit 4: Seems like others are having this problem, couldn’t find anything about it yesterday but when being more specific with the search I managed to find things like this: Unity Creating Invisible Clone (C#) - Questions & Answers - Unity Discussions
Same problem as me.

That sohnds like the start of a horror movie (“the prefab noone could see” anyone?)

That probably has nothing to do with it, because thats a crash. Because it got fixed for a min after restart, this coukd be a bug, that either noone noticed, or it didnt get fixed

1 Like

Yeah, it didn’t fix it.
Although I do think it’s to do with the animation system because it only happens after I change something to do with my Players animation. If I restart Unity and do other things it’s fine.

Then you know exactly, what’s next, create a reproduction project, and submit the bug

there is a difference between the transform and the visible mesh (assuming there is one), the transform could quite feasibly be at the origin but the mesh could be moved/displaced anywhere thanks for the animation you’re using…

Check if it’s in the scene at all: search for the name “Player” in the hierarchy search bar (top of hierarchy). It might be a child of some other transform.

If it’s not in the hierarchy, it might be hidden. Try:

Debug.Log(target.name + " " + target.transform.position + " " + target.hideFlags);

Apparently it’s quite a well known bug in Unity, I got around it by excluding the target if it contains “(Clone)”