I need help, I don't know what to do.

I am new to game development. Every time I try to add this code to my player, I get the following error message: "Can't add script behaviour 'MouseMovement'. The script needs to derive from MonoBehaviour!" Can someone explain what I need to do?
No description
3 Replies
Buddy
Buddy3d ago
Copy the contents, delete the file. Make a new file From inside Unity and then paste the code back. Make sure that the file name matches the class name Mind you that the file is unsaved, so first please try to press CTRL + S then let unity scripts compile and then try to add the component again
Buddy
Buddy3d ago
The white circle to the right of the file means changes are unsaved
No description
Anton
Anton2d ago
The file doesn't have to come from inside unity, it just has to be in the Assets directory It also has to be named the exact same that the class is named Including casing And on windows, if the file was made e.g. lower case (mousemovement) first, and then you tried to rename it to the right name (MouseMovement), it won't actually rename it You have to rename it to something different first, then rename it back with the casing fixed If you try this, it may show up correctly in the explorer, but in unity it won't work, because internally it actually retained its old name, if I had to guess You might also have broken references to a version of this script in other places. Unity can store references to types using either the namespace + class name, or the guid from the meta file

Did you find this page helpful?