for some reason I get a parsing error on the last line of this script, and I cant figure out whats wrong with it!
using UnityEngine; using System.Collections;
public class EnemyAttack : MonoBehaviour { public GameObject target; public float attacktimer; public float cooldown;
// Use this for initialization
void Start () {
attacktimer = 0;
cooldown = 1;
}
// Update is called once per frame
void Update () {
if(attacktimer > 0)
attacktimer -= Time.deltaTime;
if(attacktimer < 0)
attacktimer = 0;
if(attacktimer == 0)
Attack();
attacktimer = cooldown;
}
private void Attack() {
float distance = Vector3.Distance(target.transform.position, transform.position);
Vector3 dir = (target.transform.position - transform.position).normalized;
float direction = Vector3.Dot(dir, transform.forward);
if(distance < 3) {
if(direction > 0){
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth");
eh.AddjustCurrentHealth(-5);
}
}
}