Ok so… I am working on a survival game and my character has a knife in his hand which does damage to an enemy, the thing is I got this script which is supposed to play the animation “Attacked” when clicking the left mouse button on the object “Melee” so once I put this script I get an error saying that the variable “Melee” has not been assigned. Here is the script:
#pragma strict
var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var Melee : Transform;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
Melee.animation.Play("Attack");
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);
}
}
}
}
Also, if anyone can help me via skype with all the problems I have with the game, I would gladly appreciate.