Assets/MeleeSystem.js(12,17): BCE0044: expecting ), found ‘{’.
Assets/MeleeSystem.js(17,1): BCE0044: expecting EOF, found ‘}’.
I Got These Error’s,
This is my code:
#pragma strict
var TheDamage : int = 50;
var Distance : float;
function Update ()
{
if (Input.GetButtonDown(“Fire1”))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward, hit))
{
Distance = hit.distance;
hit.transform.SendMessage(“ApplyDamage”, TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
-
Please format your code properly. There’s a button that say 101/010. Use it.
-
I don’t really know how that error message could be any more explicit. It says that, on line 12, position 17 of the MeleeSystem.js file, it was expecting a “)”, but it found a “{”.
-
You can double click on the error message in the console log and it will even take you straight to the point in the file where the problem is. It’s hard to tell from the way you’ve pasted your code, but I’m guessing it’s probably going to be this line right here:
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward, hit)) {
-
Look at that line carefully. Why would it expect to find a “)” at the end of that line before the “{”? When would you ever expect to find a “)”… every time after you had a “(”, right? So does every one of the “(” on that line have a matching “)”?
Error messages are not random garbage that gets thrown out when the computer can’t cope. They are written, deliberately, by the programmers who make software and, more often than not, tell you exactly what’s wrong with your code and how to fix it.