void Start() { enemyHpUI = GetComponent <EnemyHpUI>(); moveCtrl = GetComponent <MoveControl>(); enemyTr = GameObject.FindGameObjectWithTag("ENEMY").GetComponent <Transform>(); tr = GetComponent <Transform>(); layerMaskEnemy = LayerMask.NameToLayer("ENEMY"); gunLight = GetComponent <Light>(); }
void AttackStart() { if (timeAfter > delay) { Debug.Log("skrksek"); timeAfter = 0f; //gunLight.enabled = true; ray.origin = shootPoint.position; ray.direction = shootPoint.forward; if (Physics.Raycast(ray, out hit, 1f, 1 << layerMaskEnemy)) { Debug.DrawRay(ray.origin, ray.direction, Color.red); Debug.Log("ray"); EnemyHpUI enemyHpUI = hit.collider.GetComponent <EnemyHpUI>(); if (enemyHpUI != null) { enemyHpUI.TakeDamage(amount: damage); } } } }