Search Unity

Help With "Ambiguity" Issue Please

Discussion in 'Scripting' started by Seldkam, Jun 28, 2018.

  1. Seldkam

    Seldkam

    Joined:
    Jun 27, 2018
    Posts:
    15
    Hi all, getting back into Unity after doing a small TTSimulator game. I've looked this up a few times but I'm no master coder and I couldn't find what I had to do to fix the "ambiguity between" the class names. Attached is the issue.

    Edit: As a side note I found a way to fix this current issue but all that fix did was create another one, so I'd rather know if there's a perfect fix for this.

     
    Last edited: Jun 28, 2018
  2. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    200
    This smells like some problem with the IDE. I'm assuming you don't have two copies of that class.

    This question might be kind of naive but did you try closing and opening the IDE?
     
  3. Seldkam

    Seldkam

    Joined:
    Jun 27, 2018
    Posts:
    15
    I did, I even restarted unity. As another bit of info, the Console in Unity itself says that "Player" has already been defined in 'global'... I've searched using ctrl + f in the whole project and the only "Player" class I can see is the public class Player you see at the top. Is there an easy way to find if I have more than 1 Player Class other than that?

    I was wondering if I'm making my own Player class and unity has its own premade version. Could that be the problem? As I edited into the OP, changing that did fix the issue but then, it creates another issue elsewhere that I'd rather not have to get into.
     
  4. Seldkam

    Seldkam

    Joined:
    Jun 27, 2018
    Posts:
    15
    Here's how I "fixed" the issue (with the other one that is created)

     
  5. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    200
    That's unlikely. I wrote a long, detailed paragraph on why and then replaced it with this: Take my word for it.

    More likely is that you have
    Player
    defined in more than one place. Look around in your folder for two Player.cs scripts. More than likely they are complete or nearly-complete duplicates, as they both seem to define a field with the same name.

    You could also try sharing your actual code, rather than pictures. Someone might sift through it and find the problem for you.
     
  6. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,298
    You've almost definitely got two classes named Player. You might be able to find the second one by going to the GameMaster.killPlayer(Player player) function and right-clicking on the word "Player" there and choosing "Go to definition". Or, press Ctrl+Shift+F and set the dropdown to "Search Entire Solution" and search for the word "Player".
     
  7. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    5,673
    It might be easier to find it using makeshiftwings method if you were to rename your known Player class temporarily to something else, and then try to find the other Player class as described.
     
  8. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,298
    Right, I was assuming you had changed it to "PlayerCode" like in the second post.