Brackeys Melee Script

This is the melee script i’m using/working with on my project.

This is my Error though
Assets/Pirate Game/MeleeScript.js(16,10): BCE0044: expecting (, found ‘AttackDamage’.

Should I put ( instead of attackdamage? tried that and it isn’t expecting that. What should I do? I don’t understand my problem.

#pragma strict

var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var cutter02 : Transform;

function Update ()
{
    if (Input.GetButtonDown ("Fire1"))
    {
        cutter02.GetComponent.<Animation>().Play("Attack");

}

function AttackDamage ()
{
        var hit : RaycastHit;
        if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
        {
            Distance = hit.distance;
            if (Distance < MaxDistance)
            {
                hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
            }       
        }   
    }
}

There’s a missing closing bracket } in line 13.

1 Like

Notice that when the code is formatted the closing bracket lines up with the opening bracket. This is useful when checking small chunks of code like this as you can run your eye down each ‘column’ & check the total # of opening brackets is the same as the # of closing brackets.

1 Like

technically { } are braces :stuck_out_tongue:

Yeah, we are just lazy & call them curly braces

Technically Lefty is righty. :sunglasses:

1 Like

Thanks so much guys I’ll fix my code when I get home tonight!!

Technically it’s a regional thing whether they’re brackets or braces. :hushed:

flower brackets (India)

awesome, I’m going to use that one :smile: