Hello guy ok what i want to do is modify my current attack script for my Enemy so that when he attacks my “attack!” animation will run at the same time. simple but not for me i have tried having an experiment i think i maybe close but it just stopped him from attacking all together. I have bin trying to ad a Boolean as i was shown by one of u lovely people in my detect script anyway any help would be appreciated but try to talk in plain language as i am still a beginner to this language :P. i will add my script below.
var target : GameObject;
var attackTimer : float;
var coolDown : float;
function Start()
{
attackTimer = 0.0;
coolDown = 1.5;
}
function Update ()
{
if(attackTimer > 0)
attackTimer -= Time.deltaTime;
if(attackTimer < 0)
attackTimer = 0;
if(attackTimer == 0)
{
Attack();
attackTimer = coolDown;
}
}
function Attack()
{
var distance = Vector3.Distance(target.transform.position, transform.position);
var dir : Vector3 = (target.transform.position - transform.position).normalized;
var direction = Vector3.Dot(dir, transform.forward);
Debug.Log(direction);
if(distance <= 2.5 && direction > 0.3)
{
var ph : PlayerHealth = target.GetComponent("PlayerHealth");
ph.AdjustCurrentHealth(-10);
}
}