Hello guyz,
I’m working on a survival game and got many help from youtube but i get problems,I have a scipt named “EnemyLogic” Before i added animation and the weapon ,The Enemy damage stopped working
Script code
#pragma strict
var Health : int = 100;
function Update ()
{
if (Health <= 0)
{
Dead();
}
}
function ApplyDamage (TheDamage : int)
{
Health -= TheDamage;
}
function Dead()
{
Destroy (gameObject);
}
#pragma strict
var Health : int = 100;
function Update ()
{
if (Health <= 0)
{
Dead();
}
}
function ApplyDamage (TheDamage : int)
{
Health -= TheDamage;
}
function Dead()
{
Destroy (gameObject);
}
#pragma strict
var Damage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var TheMace : Transform;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
TheMace.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", Damage, SendMessageOptions.DontRequireReceiver);
}
}
}
}