protected virtual void Update() { if (Input.GetKeyDown(KeyCode.A)) { sfxManager.PlaySound(sfxManager.enemyExplosionClip); } Vector3 direction = GetDirection(); transform.position += direction * speed * Time.deltaTime; }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Enemy") { sfxManager.PlaySound(sfxManager.earthHit); Destroy(collision.gameObject); hitPoints--; } else if (collision.gameObject.tag == "Moon") { Destroy(collision.gameObject); hitPoints = 0; } if (OnTakeDamage != null) { OnTakeDamage.Invoke(hitPoints); } }