- Home /
Melee Script Help
Assets/MeleeSystem.js(13,18): BCE0044: expecting :, found '='. Is the error I get . I have went through and done what it asks only to be in a slew of other errors
Here is my script.
#pragma strict
var Damage : int = 25;
var Distance : float;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.forward, hit))
(
{Distance = hit.distance;
hit.transform.SendMessage("ApplyDamage"), Damage, SendMessageOptions.DontRequireReceiver);
}
}
;
Answer by Bunny83 · Dec 03, 2013 at 03:34 AM
In line 12 you have a bracket "(", remove it. Also you should remove the semicolon at the very end of your file (line 18)
You should also tidy up your indention. In line 13 you should place the "Distance = ..." in a new line.
Variable names usually start with a lowercase letter.
ps: you're also missing the closing bracket of your Update function.
Basically something like this:
#pragma strict
var damage : int = 25;
var distance : float;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.forward, hit))
{
distance = hit.distance;
hit.transform.SendMessage("ApplyDamage"), damage, SendMessageOptions.DontRequireReceiver);
}
}
}
Never$$anonymous$$d I was stupid and didn't copy it right. Im very sorry for my lack of knowledge for these things. Im now going to tackle learning these things. Thank you for your help you have no idea what it means !
Its simple syntax... When I look at your script I'm thinking c# writer in a java script!
Your answer
![](https://koobas.hobune.stream/wayback/20220613123304im_/https://answers.unity.com/themes/thub/images/avi.jpg)