The type or namespace function could not be found
function OnTriggerEnter (Collider other) {
Application.LoadLevel("First Person Whatever");
}
What do I do here? All I want is to change the level when something collides with a specific cube, but it doesn't seem MonoDevelop knows what a function is. It comes up with the error
"The type or namespace 'function' could not be found".
I'm very new to unity, so please don't be dissapointed.Answer by ExamplesAreExamples · Nov 24, 2015 at 09:07 PM
MonoDevelop doesn't know what "function" is. It knows what text is. It knows what symbols are. It also knows about compilers, and tell compilers to compile the source text files.
The UnityScript compiler knows what "function" is.
The C# compiler doesn't know what "function" is.
Your code is mixing UnityScript ("JavaScript") and C#.
You most likely made a C# script and put UnityScript syntax into it ("function" is a UnityScript keyword, the parameter list is in C# syntax).
Decide if you want to write UnityScript or C# code.
Then change the entire script into either UnityScript or C# code.
Then make sure your file extension is either .js (UnityScript) or .cs (C#).
Your answer
Follow this Question
Related Questions
Unity CharacterController.Move Issue 0 Answers
Set public gameobject by raycast hit target 1 Answer
Help with Changing the Sprite image in the Script 0 Answers
Rotate character 0 Answers
Scripting help? 2 Answers