void AttackStart() { if (timeAfter > delay) { Debug.Log("적군이 쏨"); timeAfter = 0f; //gunLight.enabled = true; ray.origin = shootPoint.position; ray.direction = shootPoint.forward; if (Physics.Raycast(ray, out hit, 1f, 1 << layerMaskEnemy)) { ourHpSoldier = hit.collider.GetComponent <OurHpUISoldier>(); Debug.DrawRay(ray.origin, ray.direction, Color.green); Debug.Log("적군 레이저"); if (ourHpSoldier != null) { ourHpSoldier.TakeDamage2(amount: damage); } } } }
private void OnTriggerEnter(Collider other) { if (other.tag == ("PLAYER") || other.tag == "TERRAIN") { Instantiate(explosion, transform.position, Quaternion.identity); Debug.Log("60mm hit something"); if (Physics.CheckSphere(transform.position, expRadius, 1 << LayerMask.NameToLayer("PLAYER"))) { hpUICannon = other.gameObject.GetComponent <OurHpUICannon>(); hpUISoldier = other.gameObject.GetComponent <OurHpUISoldier>(); // Do Damage if (hpUICannon != null) { hpUICannon.TakeDamage1(amount: potanDamage); Debug.Log("60mm : Do Damage to Player"); } if (hpUISoldier != null) { hpUISoldier.TakeDamage2(amount: potanDamage); } } Destroy(gameObject, 2f); } Destroy(this.gameObject, 3f); }