I am currently new to coding and this software is there something wrong with this code?
#pragma strict
var Damage: int = 40;
var distance: float:
function update ()
{
if (imput.GetMouseButtonDown("Fire"1)
}
var hit : RaycastHit;
if (Physics.Raycast (Transform.position, Transform.TransformDirection(Vector3.forwdard), hit)
{
Distance = hit.distance;
hit.transform.SendMessage ("ApplyDamage", Damage, SendMessageOptions.DontRequireReciever);
}
}
}
Line 7…
if (imput.GetMouseButtonDown("Fire"1)
}
The “}” should be “{”. And “imput” should be “Input”.
I commented all the changes necessary to get it to compile:
#pragma strict
var Damage: int = 40;
var distance: float; // Need a ';' instead of a ':'
function update ()
{
if (Input.GetButtonDown("Fire1")) // Put number inside quotes; missing a ')'; 'imput' should be 'Input'; GetMouseButtonDown() should be 'GetButtonDown'
{ // Bracket backwards
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit)) // missing ')'; 'Transform' sould be 'transform'; 'forwdard' should be 'forward'
{
distance = hit.distance; // 'Distance' should be 'distance'
hit.transform.SendMessage ("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver); // 'Receiever' should be 'Receiver'
}
}
}