Hi everyone
whe coding this script monodevelop says that there is no problem with my code. But when i try to play the script unity gives me a message saying that i have a parsing error (line 41,1) and an unexpected symbol “{” error (line 37). ive spent ages on these forums and have not found an answer. Can someone help please?
using UnityEngine;
using System.Collections;
public class NumberWizard : MonoBehaviour {
// Use this for initialization
void Start () {
print ("Welcome to Number Wizard");
print ("Now pick a number in ur head");
int max = 1000;
int min = 1;
print ("the highest number you can chose is " + max);
print ("the smallest number you can pick is " + min);
print ("Is the number higher or lower than 500");
print (" Press up arrow for higher, down arrow for lower and equals for equals");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.DownArrow)){
print ("Down arrow was pressed");
}
else if (Input.GetKeyDown (KeyCode.UpArrow)){
print ("Up arrow was pressed");
}
else (Input.GetKeyDown (KeyCode.Equals)){
print ("I won");
}
}
}
using UnityEngine;
using System.Collections;
public class NumberWizard : MonoBehaviour {
// Use this for initialization
void Start () {
print ("Welcome to Number Wizard");
print ("Now pick a number in ur head");
int max = 1000;
int min = 1;
print ("the highest number you can chose is " + max);
print ("the smallest number you can pick is " + min);
print ("Is the number higher or lower than 500");
print (" Press up arrow for higher, down arrow for lower and equals for equals");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.DownArrow)){
print ("Down arrow was pressed");
}
else if (Input.GetKeyDown (KeyCode.UpArrow)){
print ("Up arrow was pressed");
}
else if (Input.GetKeyDown (KeyCode.Equals)){ // you forgot to place a if here
print ("I won");
}
}
}
so the error was that you forgot to place a if. Also for future tips when there is a error and there is a line (ect** (16,21) error) The first number "16" means to check on the vertical number(the numbers on the side)
```csharp
like this : 1
2
3
4
5
6
see the numbers on the side. you need to check those
and the second number “21” is the horizontal side like so
hello this is a error hEre.
That is a tip for the future so you can basically navigate your errors easily.
If you need any more help, feel free to tell me.
Basically this. Without the if, you can’t declare a condition. Think of else as a catch all if none of the other conditions are true. But because you have a condition, you need to include the if.