New user : No Monobehaviour scripts in the file ....

Hi,
I just started using unity today, was trying to learn from the below tutorial
http://anwell.me/articles/unity3d-flappy-bird/

Got stuck in adding a .cs script as component to my player.
When i click on .cs script it shows issues with Mono behaviour.
Ans when i click on my player , the script component shows that u need to fix some errors and script is not loaded.

Let me know what i can do to fix it.
I do not see any errors in my script.

Could you screen shot or share the issues that are being shown with Mono Behaviour? Also, if you want to insert the code(assuming you’re copying/following the tutorial), I can glance over it as I wait for some responses on my post =)

Thanks for the reply, really appreciated.

Here is the snip[pet, let me know if u need anything else

2239800--149403--issues.jpg

According to this, which seems to be the same issue.

It says to delete the script in your documents/project folder. Essentially where it would be on your disk. You’ll need to reopen your project and remake the script. But this should fix your problem!

In addition no problem! Most of the small bugs/issues like this can be found as unity has seen its fair share of users. So a little searching can go a long way. Won’t always have bored guys like me on here :wink:

Yes i got that solution while diving in forums , but i really dint saw any files on my harddisk causing this issue, hence posted here :slight_smile:

Did you delete the obstacle.cs from the project folder?

see i restarted Unity, checked any files in document/project/scripts
Still same issue

Ah that picture shows a different issue. You need to make a new script for the player, name it something. Then drag it to the player

ok ill just jot down what i am doing .

  1. I have a player, i add a component → a new script - > lets name it naval
  2. open naval.cs in editor and add code → save
  3. Now what i see is this → attaching image naval1
  4. this is the image when i click my player

For lack of ideas, the final thing posted in that other forum was an antivirus was messing with his scripts. Otherwise I’m not sure =(. Wish I could help more than I have

yes , i read that also… ok i llok for this, thanks for taking interest, will post as soon as i find something.

1 Like

Right click project window->re-import all

OR

right click the script file giving problems → reimport

Edit: Actually, I just looked at your script file. The error is telling you exactly what is wrong. Your .cs file is named “obstacle” but your class name within the file is spelt with an Uppercase O, Obstacle.

Both the name of the script and the main class within it must be exactly the same name

Your scripts have to have the same name as the class inside of them, for MonoBehaviours. You’re trying to load a component named “naval” but you’ve named the class inside of it “Player”, and it has no idea what’s going on.

Ok, looking at the other screenshots you posted, you have the same problem everywhere. C# is case sensitive. The name of your .cs file should match exactly the name of the class within the file.

Thanks all, as you guys pointed out , class n file name mismatch