Search Unity

!!!help!!!

Discussion in 'Editor & General Support' started by Unity_legacy, Feb 12, 2011.

  1. Unity_legacy

    Unity_legacy

    Joined:
    Feb 11, 2011
    Posts:
    10
    Hi,
    well this is my first thread,so i hope I'm doing it right...lol...

    So,I've got a problem with Unity 2.6.1. I can't add scripts to game objects. When I try to, it always says:

    Can't add script

    Can't add script behaviour MachineGun. The scripts file name does not match the name of the class defined in the script!

    What should I do?

    Thanks to anyone who answers!!!
     
  2. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    I think it refers to the name at the top of your script

    Look at the top of your script, it says

    public class NewBehaviourScript : MonoBehaviour {



    If your script is called MachineGun then the above line should be changed to
    public class MachineGun : MonoBehaviour


    This is what I do in c# anyway.
     
  3. WinningGuy

    WinningGuy

    Joined:
    Aug 10, 2009
    Posts:
    884
    In general, you might want to use a more descriptive title for your thread than, "!!!help!!!". Otherwise, people who may be able to help you might just skip over it.

    Ok, so it looks like you named your script MachineGun. Is this a script that you created? If not, did you rename it from something else?

    When you look in the script, is the class name MachineGun?
     
  4. Unity_legacy

    Unity_legacy

    Joined:
    Feb 11, 2011
    Posts:
    10
    @WinningGuy:
    Well, I didn't create the script. It was a pre-made script in the fps tutorial from unity3d.com.
    It isn't on the website anymore but I found it with Google.
     
  5. minevr

    minevr

    Joined:
    Mar 4, 2008
    Posts:
    1,018
    double files....
    delete one..
     
  6. Unity_legacy

    Unity_legacy

    Joined:
    Feb 11, 2011
    Posts:
    10
    Now it works...
    I deleted it from my desktop and now it works!
    Thanks anyway, guys:D:D:D
     
  7. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    What does that have to do with the title of the thread?