2
\$\begingroup\$

I just updated Unity to 5.4 today, though as I saw, this problem was present in previous versions too.

So the error message is :

The type or namespace name 'FirstPersonController' could not be found (are you missing a using directive or an assembly reference?)

This happens when I try to reference the FPSController prefab's FirstPersonController.cs (obviously I'm talking about the one from StandardAssets/Characters).

Yes, I did try including

using *UnityStandardAssets.Characters.FirstPerson*

in my script, but no, it did not work. Doesn't even recognize is as a valid namespace.

The same happens when I try the other way: when I try referencing my script inside the FirstPersonController.cs. It just doesn't recognize it as valid.

Anybody has any idea how to solve it?

\$\endgroup\$
  • \$\begingroup\$ Is the file name the same name as the class? \$\endgroup\$ – SuperSquareBoy Sep 12 '16 at 22:19
  • \$\begingroup\$ Yes. Anyway, weeks later, now it's working. I have no idea how or why, but now it recognizes the UnityStandardAssets namespace and the others as well. So now I can just use FirstPersonController and a static variable I made inside it and modify it so it works just like I wanted. Weird though \$\endgroup\$ – spartai Sep 25 '16 at 18:18
1
\$\begingroup\$

I had an identical issue with the AeroplaneController script.

While I do not acknowledge it as the absolute solution, I solved the issue by actually moving the script to my local scripts folder.

The problem appears to be in having native access to scripts across a folder hierarchy. If script A is in a different parent folder to script B, neither will have the ability to immediately reference each other.

Ofcourse, this added some other problems. In my case, AeroplaneController referenced one or two scripts (or was referenced by, I honestly can not remember for sure), and moving it outside of the folder structure removed the ability to see the other scripts / AeroplaneController from the other scripts. I would have either moved the important scripts, as well, or removed the reference to AeroplaneController in the unimportant scripts simply to remove the error.

|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

It sounds like you have a conflict between the versions of unity the project is referencing.

Are you using VS to edit your scripts? If so, expand the references node in the solution explorer and see if you have any missing/broken references.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.