Im using this code and the error says that its expecting EOF, found ‘}’. WHAT DO I DO I NEED HELP!!!
#pragma strict
var TheDamage : int = 50;
var Distance : float;
function Update ()
{
if (input.GetMouseButtonDown("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward, hit))
)
Distance = hit.distance;
hit.transform.SendMessage("ApplyDammage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
Your code doesn’t contain an “else” so there’s probably more code after that Update function. However the cause of the problem is most likely that you’re missing an opening curly bracket at the end of line 10, after your Physics.Raycast if statement.
@Bunny83 I fixed that but now its coming up with an error saying looking for } but found ‘’.?
Im not really sure what to do thx!
#pragma strict
var TheDammage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
var hit : RaycastHit;
if (Physics.Raycast (TheSystem.transform.position, TheSystem.transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}