I’m trying to get a script component from another script. Both scripts are attached to the same gameobject.
I tried:
GetComponent<TheScriptIWantToGet>();
But I’m getting…
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'TheScriptIWantToGet' could not be found (are you missing a using directive or an assembly reference?)
You’re doing it correctly. Some would write gameObject.getComponent to make it more obvious it’s a script on you, but that’s not needed. There’s likely a problem with your script name. Misspelled, or it’s inside another namespace, or your code editor is hooked up wrong (Unity itself will be fine, and it will run, but intellisense falsely claims it’s not there).
As a test, you might try to find your own script. If the computer can’t find that name, something is very wrong.