public void Fire(Vector3 position, Vector3 direction) { transform.position = position; transform.forward = direction; gameObject.layer = LayerMask.NameToLayer("EnemyProjectile"); gameObject.SetActive(true); rb.isKinematic = false; rb.velocity = Vector3.zero; rb.AddForce(direction * 80, ForceMode.Impulse); hit = maxHit; healthBar.UpdateHealth(hit, maxHit); attacking = true; }
public void TakeDamage(int damage) { health -= damage; if (health <= 0) { OnDeath(); } healthBar.UpdateHealth(health, maxHealth); }