Invalid PlayerController script

When I split the Mover script into two, I wasn’t able to upload it to player


, then i created a new script, copied and pasted the old script into the new one and despite having it connected to the player, it still didn’t work
image
In console, it looks like this :

Of course I’ve checked the code multiple times before i did it, but i couldn’t find any flaw.
The PlayerController script looks like this :


i put there and option to move with WASD and to toggle between these modes, that’s all I did differently than in the video.

Found what the problem was, sorry for the fuss, i said myself I’m gonna check it one more time, then I’m gonna make some tea. And I found the error, the name was PlayerController and public class was
Playercontroller : MonoBehaviour
this error was probably created when i created the file, and then renamed it, so if you rename a script, make sure to rename the class too. :slight_smile:

1 Like

That’s correct. Both MonoBehaviours and ScriptableObjects have the very strict requirement that the filename must match the class name exactly. Enums, structs, and classes that are not MonoBehaviour and ScriptableObjects do not have this requirement.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms