using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Chase : MonoBehaviour {
public float Timer = 2;
public GameObject firePoint;
public List<GameObject> vfx = new List<GameObject> ();
private GameObject effectToSpawn;
Animator animator;
GameObject attackDetectionGObject;
Enemy enemy;
float rotatingSpeed = 10f;
bool isAttacking = false;
public Transform target;
bool enter;
int count = 1;
public float myVolume = 1.0f;
public AudioClip attacksound;
public AudioSource source;
void Start() {
animator = GetComponent<Animator>();
attackDetectionGObject = this.transform.Find("robot_lrg/root/spine05/spine04/spine03/spine02/spine01/clavicle_R/shoulder01_R/upperarm01_R/upperarm02_R/lowerarm01_R/lowerarm02_R/wrist_R/Shifi_sword/AttackDetection").gameObject;
target = GameObject.FindGameObjectWithTag("Player").transform;
enemy = GetComponent<Enemy>();
effectToSpawn = vfx [0];
}
void FixedUpdate() {
if(enemy.isDead) return;
if(Vector3.Distance(target.position, this.transform.position) < 10) {
Vector3 direction = target.position - this.transform.position;
direction.y = 0;
this.transform.rotation = Quaternion.Slerp(this.transform.rotation, Quaternion.LookRotation(direction), rotatingSpeed * Time.deltaTime);
animator.SetBool("isIdle", false);
if (direction.magnitude > 6.3f) {
Timer -= Time.deltaTime;
if (Timer <= 0f) {
SpawnVFX ();
Timer = 3f;
}
}
if(direction.magnitude > 2.3f) {
this.transform.Translate(0, 0, 0.02f);
animator.SetBool("isWalking", true);
animator.SetBool("isAttacking", false);
}
else {
animator.SetBool("isWalking", false);
animator.SetBool("isAttacking", true);
animator.SetBool("isAttackingdue", false);
oksound ();
StartCoroutine(EnableAttackDetection());
}
}
else {
attackDetectionGObject.GetComponent<Collider>().enabled = false;
animator.SetBool("isIdle", true);
animator.SetBool("isWalking", false);
animator.SetBool("isAttacking", false);
}
}
IEnumerator EnableAttackDetection() {
isAttacking = true;
attackDetectionGObject.GetComponent<Collider>().enabled = false;
yield return new WaitForSeconds(0.5f);
attackDetectionGObject.GetComponent<Collider>().enabled = true;
yield return new WaitForSeconds(0.5f);
isAttacking = false;
attackDetectionGObject.GetComponent<Collider>().enabled = false;
yield break;
}
void oksound(){
enter = true;
// Play the sound only on the trigger
if (enter && count ==1) {
source.PlayOneShot (attacksound, myVolume);
count -= 1;
}
}
void SpawnVFX(){
GameObject vfx;
animator.SetBool ("isAttackingdue", true);
if(firePoint != null){
vfx = Instantiate(effectToSpawn, firePoint.transform.position, Quaternion.identity);
vfx.transform.localRotation = firePoint.transform.rotation;
} else{
Debug.Log("No Fire Point");
}
}
}
error (59,12): 'Enemy' does not contain a definition for 'isDead' and no accessible extension method
What line?
You have not included the code for the Enemy class. It might be a case of having a private isDead instead of public, or something else entirely.