Error CS0246: Type/Namespace Error

Hi guys,
I’m getting this error:
error CS0246: The type or namespace name `CharacterMovement’ could not be found. Are you missing a using directive or an assembly reference?

The script is trying to reference the script “CharacterMovement” on the same gameObject level as itself, but it’s coming up with this namespace error. I’m using the following line of code to try to access “CharacterMovement”:

GetComponent<CharacterMovement>().enabled = true;

I have noted that with some of the SampleAsset Scripts, I can say,

using UnitySampleAssets.Utility;

or something similar, but this is a custom script. Do you have any idea how to fix this?

ViolinRobot

see this: error CS0246 missing type or namespace... - Questions & Answers - Unity Discussions
i think this is the solution for you :slight_smile:

Are you sure the script is called CharacterMovement? It could be something as simple as a misspelt word.

Hi, first of all your script CharacterMovement must be a public class. Make a reference in the other script that is trying to access it: CharacterMovement charMov; and in the Start method write charMov = GetComponent(); Should work