- Home /
Error when using GetComponent<> in a C# script, on a javascript
Hello,
I'm currently making a little script that switches between two cameras. One camera is written in C# (MouseLook) and the other in Javascript (SmoothFollow)
When I use GetComponent<SmoothFollow>().enabled = false;
I get the error The type or namespace name 'SmoothFollow' could not be found. Are you missing a using directive or an assembly reference?
Somewhere else I'm using GetComponent<MouseLook>().enabled = false;
And that works just fine.
Answer by TowerOfBricks · Jun 01, 2011 at 08:33 PM
You will need to place the js script in the Standard Assets folder or Plugins folder. See unity documentation for more info. http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html
This is super dumb, tripped me up for ages, not working until both scripts were in the same folder for some reason, even though both scripts were added to the same gameobject
Answer by Anton1274 · Oct 24, 2014 at 07:50 AM
Yes you need to put the js script in ste standard asset folder because, it's compiled before che c# script.... If you wanna make a project select one kind of language script and use it ever.