void shoot() { timer = 0f; shotaudio.Play(); shotlight.enabled = true; shotline.enabled = true; shotline.SetPosition(0, transform.position); rayshot.direction = transform.forward; // Invoke("attend", 1); if (Physics.Raycast(transform.position, transform.forward, out hit)) { enmyhealth eh = hit.collider.GetComponent <enmyhealth>(); if (eh != null) { eh.gethurt(shotdamage); anim = hit.collider.GetComponent <Animator>(); anim.SetBool("isFrapp", true); Invoke("finanim", 2); shotline.SetPosition(1, hit.point); } } else { shotline.SetPosition(1, transform.position + range * transform.forward); } // Invoke("destory", 1f); }
void Awake() { anim = GetComponentInChildren <Animator>(); eh = enmy.GetComponent <enmyhealth>(); // pma =GetComponent<UnityEngine.AI.NavMeshAgent>(); od = door.GetComponent <opendoor>(); }
void Shoot() { RaycastHit hitInfo; if (Physics.Raycast(transform.position, transform.forward, out hitInfo, 50f)) { enmyhealth target = hitInfo.transform.GetComponent <enmyhealth>(); if (target != null) { target.gethurt(damage); GameObject impactGO = Instantiate(impactEffect, hitInfo.point, Quaternion.LookRotation(hitInfo.normal)); Destroy(impactGO, 1f); } } }
void Start() { //anim = GetComponent<Animator> ();hg anim = GetComponentInChildren <Animator>(); eh = GetComponent <enmyhealth> (); }