Search Unity

Strangely GameObject Clone in the Stealth project tutorial

Discussion in 'Editor & General Support' started by TuringM, Dec 21, 2013.

  1. TuringM

    TuringM

    Joined:
    Dec 21, 2013
    Posts:
    3
    Hello!

    I'm really new to Unity, and while doing the Stealth tutorial, many scripts didn't work properly. After fiddling a bit, I figured out that
    Code (csharp):
    1. GameObject.FindGameObjectsWithTag(Tags.player)
    returned two player objects. The first one returned is at (0,0,0) and is named "char_ethan(Clone)", but does not appear on the scene, even in play mode. It's strange since I have only one player in my hierarchy! And I never wrote any script that instanciates another player.

    Besides, I noticed that a laser switch was incorrectly linked to the fx_laserFence_lasers_001 prefab (btw there is a little mistake in the tutorial naming the laser before making the prefab) instead of its instance. But I think the problem with "char_ethan(Clone)" is something else...

    Actually, I made a static function that always return the last GameObject having the tag "Player" to select the real player instead of the clone, but if anyone know how to get rid of this clone, and how it appeared, to prevent me to make the mistake again, he would be very welcome :)
     
  2. TuringM

    TuringM

    Joined:
    Dec 21, 2013
    Posts:
    3
    The problem have been solved by itself... I did nothing in particular for that. Now it seems like the Clone definitively disappeared...
    I would love to understand how it appeared and why it disappeared. I still consider it as a bug for now...
     
  3. SML

    SML

    Joined:
    Mar 5, 2014
    Posts:
    1
    I have encountered the same problem. GameObject.FindGameObjectsWithTag(Tags.player) returned 11 objects named "char_ethan(Clone)" and the player (in that order). The clones did not exist in the hierarchy. The resulting transform remained at (0,0,0)

    Closing and relaunching Unity fixes the problem. I emphasize that so people googling the problem will not spend too much time searching a bug in their code ;)

    It seems that when working on the tutorial steps, the tag management became corrupted at some point. I have added some lines to raise an error if it happens again when finishing the tutorial in the hope to send a 100% reproducible bug report.

    It looks like a minor problem (related to Player tag only?) that will cause unnecessary headaches if you work too long on Unity without closing it. So, when in doubt... take a break!
     
    Last edited: Mar 12, 2014
  4. Isamaru

    Isamaru

    Joined:
    Feb 17, 2014
    Posts:
    2
    I have been experiencing this myself now that I started working on my own project after learning the basics from the Stealth tutorial.

    After going mad for a couple of hours I noticed that the problem is referencing the Player object by tag inside a script attached to it. This somehow spawns a clone of the object under certain circumstances (after a few edits/plays) and in my case the animator got attached to that instead of the original object in the scene.

    The solution in my case was simple:
    Code (csharp):
    1. anim = GetComponent<Animator> ();
    avoids any problem.