Weatas
1
(3,4)uce0001 ‘;’ expected. insert a semicolon at the end.
(3,5)bce0044: expecting EOF, found ‘thedammage’.
Here is my script
#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 (Transform.position, transform.TransformDirection (Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
}
(please Help me out)
Landern
2
You have four mistakes in your code.
The first three are the case of “var”, it should be lower case.
The second is in the first parameter of Physicis.Raycast, you are passing a type instead of the transform of the object the script is attached to.
The update function has a capital U, so “function Update()”
Also always format your code, i’ve done it for you, i will not in the future.
#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 (transform.position, transform.TransformDirection (Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
}