- Home /
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
And is Character$$anonymous$$ovement written in the same language (c#/UnityScript) as this script?
Is both the name of the script and the name of the class Character$$anonymous$$ovement?
Thanks so much guys. Another related issue is that I can't enable a script in one of the children of my gameObject, even with
GetComponentInChildren<>()
Do you have any idea how I could reference it?
Answer by fares90 · Aug 15, 2015 at 10:24 AM
see this: http://answers.unity3d.com/questions/304724/error-cs0246-missing-type-or-namespace.html i think this is the solution for you :)
Answer by Tom01098 · Aug 15, 2015 at 01:05 PM
Are you sure the script is called CharacterMovement? It could be something as simple as a misspelt word.
Answer by moriggi · Aug 15, 2015 at 03:05 PM
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
Your answer
Follow this Question
Related Questions
CSharpMsgrExtended: CS0246: The type or namespace name `Exception' could not be found. 2 Answers
The type or namescape name 'ModifyingAttribute' could not be found. 2 Answers
How I can fix This? HELP ME! 0 Answers
Project structure, finding scripts vis GetComponent and related errors 1 Answer
error CS0246: The type or namespace name `rect' could not be found. 1 Answer